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

[5.4.0-beta5] Changed revoking to locking #3109

Merged
merged 3 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ All notable changes to this project will be documented in this file.
- Reveal hidden voters if hidden in case of performance concerns
- Support better readability of vote page
- Added revoking of shares
- Shares can now be revoked which works as a read only share mechanism. Revoked shares can still enter the poll, but all interaction (voting and commenting) is disabled.
- Deletion of unsent shares have no more a redo timer
- Deletion of revoked shares deletes the users votes as well
- 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
- Improved username check for public polls with a large number of groups in the backend
## [5.3.2] - 2023-09-11
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>Polls</name>
<summary>A polls app, similar to Doodle/Dudle with the possibility to restrict access.</summary>
<description>A polls app, similar to Doodle/Dudle with the possibility to restrict access (members, certain groups/users, hidden and public).</description>
<version>5.4.0-beta5</version>
<version>5.4.0-beta6</version>
<licence>agpl</licence>
<author>Vinzenz Rosenkranz</author>
<author>René Gieling</author>
Expand Down
4 changes: 2 additions & 2 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
['name' => 'share#admin_to_user', 'url' => '/share/{token}/user', 'verb' => 'PUT'],
['name' => 'share#set_label', 'url' => '/share/{token}/setlabel', 'verb' => 'PUT'],
['name' => 'share#set_public_poll_email', 'url' => '/share/{token}/publicpollemail/{value}', 'verb' => 'PUT'],
['name' => 'share#revoke', 'url' => '/share/{token}/revoke', 'verb' => 'PUT'],
['name' => 'share#re_revoke', 'url' => '/share/{token}/rerevoke', 'verb' => 'PUT'],
['name' => 'share#lock', 'url' => '/share/{token}/lock', 'verb' => 'PUT'],
['name' => 'share#unlock', 'url' => '/share/{token}/unlock', 'verb' => 'PUT'],

['name' => 'settings#getAppSettings', 'url' => '/settings/app', 'verb' => 'GET'],
['name' => 'settings#writeAppSettings', 'url' => '/settings/app', 'verb' => 'POST'],
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@ public function delete(string $token): JSONResponse {
* @NoAdminRequired
*/

public function revoke(string $token): JSONResponse {
return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->revoke(token: $token)]);
public function lock(string $token): JSONResponse {
return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->lock(token: $token)]);
}

/**
* Delete share
* @NoAdminRequired
*/

public function reRevoke(string $token): JSONResponse {
return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->reRevoke(token: $token)]);
public function unlock(string $token): JSONResponse {
return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->unlock(token: $token)]);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions lib/Db/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
* @method void setInvitationSent(integer $value)
* @method int getReminderSent()
* @method void setReminderSent(integer $value)
* @method int getRevoked()
* @method void setRevoked(integer $value)
* @method int getLocked()
* @method void setLocked(integer $value)
* @method string getDisplayName()
* @method void setDisplayName(string $value)
* @method string getMiscSettings()
Expand Down Expand Up @@ -123,15 +123,15 @@ class Share extends Entity implements JsonSerializable {
protected ?string $emailAddress = null;
protected int $invitationSent = 0;
protected int $reminderSent = 0;
protected int $revoked = 0;
protected int $locked = 0;
protected ?string $displayName = null;
protected ?string $miscSettings = '';
protected int $voted = 0;

public function __construct() {
$this->addType('pollId', 'int');
$this->addType('invitationSent', 'int');
$this->addType('Revoked', 'int');
$this->addType('Locked', 'int');
$this->addType('reminderSent', 'int');
$this->urlGenerator = Container::queryClass(IURLGenerator::class);
$this->appSettings = new AppSettings;
Expand All @@ -150,7 +150,7 @@ public function jsonSerialize(): array {
'emailAddress' => $this->getEmailAddress(),
'invitationSent' => $this->getInvitationSent(),
'reminderSent' => $this->getReminderSent(),
'revoked' => $this->getRevoked(),
'locked' => $this->getLocked(),
'displayName' => $this->getDisplayName(),
'isNoUser' => !(in_array($this->getType(), [self::TYPE_USER, self::TYPE_ADMIN], true)),
'URL' => $this->getURL(),
Expand Down
2 changes: 1 addition & 1 deletion lib/Event/ShareEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class ShareEvent extends BaseEvent {
public const CHANGE_REG_CONSTR = 'share_change_reg_const';
public const REGISTRATION = 'share_registration';
public const DELETE = 'share_delete';
public const REVOKED = 'share_revoked';
public const LOCKED = 'share_locked';

private Share $share;
// protected UserBase $sharee = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

use OCA\Polls\Db\Share;

class ShareRevokedEvent extends ShareEvent {
class ShareLockedEvent extends ShareEvent {
public function __construct(Share $share) {
parent::__construct($share);
$this->eventId = self::REVOKED;
$this->eventId = self::LOCKED;
}
}
3 changes: 2 additions & 1 deletion lib/Migration/TableSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ abstract class TableSchema {
Share::TABLE => [
'user', // dropped in 1.01
'user_email', // dropped in 1.06 and migrated to email_address
'revoked', // introduced in 5.4.0-beta3 and replaced with column 'locked' in 5.4.0-beta5, no migration
],
Log::TABLE => [
'message', // dropped in 1.07, orphaned
Expand Down Expand Up @@ -218,7 +219,7 @@ abstract class TableSchema {
'display_name' => ['type' => Types::STRING, 'options' => ['notnull' => false, 'default' => null, 'length' => 256]],
'email_address' => ['type' => Types::STRING, 'options' => ['notnull' => false, 'default' => null, 'length' => 256]],
'invitation_sent' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],
'revoked' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],
'locked' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],
'reminder_sent' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],
'misc_settings' => ['type' => Types::TEXT, 'options' => ['notnull' => false, 'default' => null, 'length' => 65535]],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* Changed class naming: Version[jjmmpp]Date[YYYYMMDDHHMMSS]
* Version: jj = major version, mm = minor, pp = patch
*/
class Version050400Date20231011211202 extends SimpleMigrationStep {
class Version050400Date20231011211203 extends SimpleMigrationStep {
private ISchemaWrapper $schema;

public function __construct(
Expand Down
8 changes: 4 additions & 4 deletions lib/Model/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private function getIsDelegatedAdmin(): bool {
}

if ($this->loadShare()) { // load share, if not loaded
return $this->share->getType() === Share::TYPE_ADMIN && !$this->share->getRevoked();
return $this->share->getType() === Share::TYPE_ADMIN && !$this->share->getLocked();
};
return false;
}
Expand Down Expand Up @@ -480,7 +480,7 @@ private function getAllowAddOptions(): bool {
return false; // Request for option proposals is expired, deny
}

if ($this->share?->getRevoked()) {
if ($this->share?->getLocked()) {
return false; // Request for option proposals is expired, deny
}

Expand All @@ -499,7 +499,7 @@ private function getAllowComment(): bool {
return false; // public shares are not allowed to comment
}

if ($this->share?->getRevoked()) {
if ($this->share?->getLocked()) {
return false; // public shares are not allowed to comment
}

Expand All @@ -518,7 +518,7 @@ private function getAllowVote(): bool {
return false; // public shares are not allowed to vote
}

if ($this->share?->getRevoked()) {
if ($this->share?->getLocked()) {
return false; // public shares are not allowed to vote
}

Expand Down
16 changes: 8 additions & 8 deletions lib/Service/ShareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
use OCA\Polls\Event\ShareChangedRegistrationConstraintEvent;
use OCA\Polls\Event\ShareCreateEvent;
use OCA\Polls\Event\ShareDeletedEvent;
use OCA\Polls\Event\ShareLockedEvent;
use OCA\Polls\Event\ShareRegistrationEvent;
use OCA\Polls\Event\ShareRevokedEvent;
use OCA\Polls\Event\ShareTypeChangedEvent;
use OCA\Polls\Exceptions\ForbiddenException;
use OCA\Polls\Exceptions\InvalidShareTypeException;
Expand Down Expand Up @@ -327,31 +327,31 @@ public function delete(Share $share = null, string $token = null): string {
}

/**
* Revoke share
* Lock share
*/
public function revoke(Share $share = null, string $token = null): string {
public function lock(Share $share = null, string $token = null): string {
if ($token) {
$share = $this->shareMapper->findByToken($token);
}
$this->acl->setPollId($share->getPollId(), Acl::PERMISSION_POLL_EDIT);

$share->setRevoked(time());
$share->setLocked(time());
$this->shareMapper->update($share);
$this->eventDispatcher->dispatchTyped(new ShareRevokedEvent($share));
$this->eventDispatcher->dispatchTyped(new ShareLockedEvent($share));

return $share->getToken();
}

/**
* Re-revoke share
* Unlock share
*/
public function reRevoke(Share $share = null, string $token = null): string {
public function unlock(Share $share = null, string $token = null): string {
if ($token) {
$share = $this->shareMapper->findByToken($token);
}
$this->acl->setPollId($share->getPollId(), Acl::PERMISSION_POLL_EDIT);

$share->setRevoked(0);
$share->setLocked(0);
$this->shareMapper->update($share);
$this->eventDispatcher->dispatchTyped(new ShareCreateEvent($share));

Expand Down
12 changes: 6 additions & 6 deletions src/js/Api/modules/shares.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ const shares = {
})
},

revokeShare(shareToken) {
lockShare(shareToken) {
return httpInstance.request({
method: 'PUT',
url: `share/${shareToken}/revoke`,
cancelToken: cancelTokenHandlerObject[this.revokeShare.name].handleRequestCancellation().token,
url: `share/${shareToken}/lock`,
cancelToken: cancelTokenHandlerObject[this.lockShare.name].handleRequestCancellation().token,
})
},

reRevokeShare(shareToken) {
unlockShare(shareToken) {
return httpInstance.request({
method: 'PUT',
url: `share/${shareToken}/rerevoke`,
cancelToken: cancelTokenHandlerObject[this.reRevokeShare.name].handleRequestCancellation().token,
url: `share/${shareToken}/unlock`,
cancelToken: cancelTokenHandlerObject[this.unlockShare.name].handleRequestCancellation().token,
})
},

Expand Down
8 changes: 4 additions & 4 deletions src/js/components/Actions/modules/ActionDelete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<UndoIcon v-if="deleteTimeout"
:size="iconSize"
@click="cancelDelete()" />
<RevokeIcon v-else-if="revoke"
<LockIcon v-else-if="lock"
:size="iconSize"
@click="deleteItem()" />
<DeleteIcon v-else
Expand All @@ -43,14 +43,14 @@
<script>
import { NcButton } from '@nextcloud/vue'
import DeleteIcon from 'vue-material-design-icons/Delete.vue'
import RevokeIcon from 'vue-material-design-icons/Close.vue'
import LockIcon from 'vue-material-design-icons/Lock.vue'
import UndoIcon from 'vue-material-design-icons/ArrowULeftTop.vue'

export default {
name: 'ActionDelete',
components: {
DeleteIcon,
RevokeIcon,
LockIcon,
UndoIcon,
NcButton,
},
Expand All @@ -69,7 +69,7 @@ export default {
type: Number,
default: 20,
},
revoke: {
lock: {
type: Boolean,
default: false,
},
Expand Down
Loading
Loading