Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forgotten changes #3111

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file.
### New
- Reveal hidden voters if hidden in case of performance concerns
- Support better readability of vote page
- Added revoking of shares
- Added locking of shares
- Shares can now be locked which works as a read only share mechanism. Locked shares can still enter the poll, but every interaction (voting and commenting) is disabled.
- Deletion of locked shares deletes the users votes as well
### Changes
Expand Down
4 changes: 2 additions & 2 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@
['name' => 'share_api#add', 'url' => '/api/v1.0/poll/{pollId}/share/{type}', 'verb' => 'POST'],
['name' => 'share_api#delete', 'url' => '/api/v1.0/share/{token}', 'verb' => 'DELETE'],
['name' => 'share_api#sendInvitation', 'url' => '/api/v1.0/share/send/{token}', 'verb' => 'PUT'],
['name' => 'share_api#revoke', 'url' => '/api/v1.0/share/revoke/{token}', 'verb' => 'PUT'],
['name' => 'share_api#re_revoke', 'url' => '/api/v1.0/share/rerevoke/{token}', 'verb' => 'PUT'],
['name' => 'share_api#lock', 'url' => '/api/v1.0/share/lock/{token}', 'verb' => 'PUT'],
['name' => 'share_api#unlock', 'url' => '/api/v1.0/share/unlock/{token}', 'verb' => 'PUT'],

['name' => 'subscription_api#get', 'url' => '/api/v1.0/poll/{pollId}/subscription', 'verb' => 'GET'],
['name' => 'subscription_api#subscribe', 'url' => '/api/v1.0/poll/{pollId}/subscription', 'verb' => 'PUT'],
Expand Down
20 changes: 20 additions & 0 deletions lib/Controller/ShareApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@ public function delete(string $token): JSONResponse {
return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->delete(token: $token)]);
}

/**
* Lock share
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*/
public function lock(string $token): JSONResponse {
return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->lock(token: $token)]);
}

/**
* Unlock share
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*/
public function unlock(string $token): JSONResponse {
return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->unlock(token: $token)]);
}

/**
* Sent invitation mails for a share
* @NoAdminRequired
Expand Down
8 changes: 4 additions & 4 deletions src/js/components/Shares/ShareItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ export default {
showSuccess(t('polls', 'Share for user {displayName} locked', { displayName: share.displayName }))
}
} catch (e) {
showError(t('polls', 'Error deleting or revoking share for user {displayName}', { displayName: share.displayName }))
console.error('Error deleting or revoking share', { share }, e.response)
showError(t('polls', 'Error while changing lock status for user {displayName}', { displayName: share.displayName }))
console.error('Error locking or unlocking share', { share }, e.response)
}
},

Expand All @@ -228,8 +228,8 @@ export default {
showSuccess(t('polls', 'Deleted share for user {displayName}', { displayName: share.displayName }))
}
} catch (e) {
showError(t('polls', 'Error deleting or revoking share for user {displayName}', { displayName: share.displayName }))
console.error('Error deleting or revoking share', { share }, e.response)
showError(t('polls', 'Error deleting share for user {displayName}', { displayName: share.displayName }))
console.error('Error deleting share', { share }, e.response)
}
},

Expand Down
4 changes: 2 additions & 2 deletions src/js/store/modules/shares.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const actions = {
context.dispatch('list')
} catch (e) {
if (e?.code === 'ERR_CANCELED') return
console.error('Error revoking share', { error: e.response }, { payload })
console.error('Error locking share', { error: e.response }, { payload })
context.dispatch('list')
throw e
}
Expand All @@ -198,7 +198,7 @@ const actions = {
context.dispatch('list')
} catch (e) {
if (e?.code === 'ERR_CANCELED') return
console.error('Error re-revoking share', { error: e.response }, { payload })
console.error('Error unlocking share', { error: e.response }, { payload })
context.dispatch('list')
throw e
}
Expand Down