From 8d4e291d4ce1cd3a6c9f626b0c01a8eff7d04e16 Mon Sep 17 00:00:00 2001 From: dartcafe Date: Sun, 15 Oct 2023 21:31:17 +0200 Subject: [PATCH] forgotten changed Signed-off-by: dartcafe --- CHANGELOG.md | 2 +- appinfo/routes.php | 4 ++-- lib/Controller/ShareApiController.php | 20 ++++++++++++++++++++ src/js/components/Shares/ShareItem.vue | 8 ++++---- src/js/store/modules/shares.js | 4 ++-- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd597ac2c..5f770de01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/appinfo/routes.php b/appinfo/routes.php index 648996c17..01c9ef7d9 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -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'], diff --git a/lib/Controller/ShareApiController.php b/lib/Controller/ShareApiController.php index 4ed73a8e5..759ff98fa 100644 --- a/lib/Controller/ShareApiController.php +++ b/lib/Controller/ShareApiController.php @@ -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 diff --git a/src/js/components/Shares/ShareItem.vue b/src/js/components/Shares/ShareItem.vue index 05e53cb46..34815ba65 100644 --- a/src/js/components/Shares/ShareItem.vue +++ b/src/js/components/Shares/ShareItem.vue @@ -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) } }, @@ -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) } }, diff --git a/src/js/store/modules/shares.js b/src/js/store/modules/shares.js index f0d22199b..703c64520 100644 --- a/src/js/store/modules/shares.js +++ b/src/js/store/modules/shares.js @@ -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 } @@ -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 }