From cf58a31c928174166aab6bfdf81c9a99e6308b39 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 14 Sep 2022 08:40:32 +0200 Subject: [PATCH 1/3] Reset the poll and vote author information to be GDPR compliant Signed-off-by: Joas Schilling --- lib/Listener/UserDeletedListener.php | 8 ++- lib/Service/PollService.php | 20 ++++++++ tests/integration/features/chat/poll.feature | 53 ++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/lib/Listener/UserDeletedListener.php b/lib/Listener/UserDeletedListener.php index 17a589f4c5f..229616ecb74 100644 --- a/lib/Listener/UserDeletedListener.php +++ b/lib/Listener/UserDeletedListener.php @@ -24,15 +24,19 @@ namespace OCA\Talk\Listener; use OCA\Talk\Manager; +use OCA\Talk\Model\Attendee; +use OCA\Talk\Service\PollService; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\User\Events\UserDeletedEvent; class UserDeletedListener implements IEventListener { private Manager $manager; + private PollService $pollService; - public function __construct(Manager $manager) { + public function __construct(Manager $manager, PollService $pollService) { $this->manager = $manager; + $this->pollService = $pollService; } public function handle(Event $event): void { @@ -43,5 +47,7 @@ public function handle(Event $event): void { $user = $event->getUser(); $this->manager->removeUserFromAllRooms($user); + + $this->pollService->neutralizeDeletedUser(Attendee::ACTOR_USERS, $user->getUID()); } } diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php index 78cdb87fc80..10f6cdda186 100644 --- a/lib/Service/PollService.php +++ b/lib/Service/PollService.php @@ -333,4 +333,24 @@ public function updateDisplayNameForActor(string $actorType, string $actorId, st ->andWhere($update->expr()->eq('actor_id', $update->createNamedParameter($actorId))); $update->executeStatement(); } + + public function neutralizeDeletedUser(string $actorType, string $actorId): void { + $update = $this->connection->getQueryBuilder(); + $update->update('talk_polls') + ->set('display_name', $update->createNamedParameter('')) + ->set('actor_type', $update->createNamedParameter('deleted_users')) + ->set('actor_id', $update->createNamedParameter('deleted_users')) + ->where($update->expr()->eq('actor_type', $update->createNamedParameter($actorType))) + ->andWhere($update->expr()->eq('actor_id', $update->createNamedParameter($actorId))); + $update->executeStatement(); + + $update = $this->connection->getQueryBuilder(); + $update->update('talk_poll_votes') + ->set('display_name', $update->createNamedParameter('')) + ->set('actor_type', $update->createNamedParameter('deleted_users')) + ->set('actor_id', $update->createNamedParameter('deleted_users')) + ->where($update->expr()->eq('actor_type', $update->createNamedParameter($actorType))) + ->andWhere($update->expr()->eq('actor_id', $update->createNamedParameter($actorId))); + $update->executeStatement(); + } } diff --git a/tests/integration/features/chat/poll.feature b/tests/integration/features/chat/poll.feature index d7acc1692a5..ab77b2194c3 100644 --- a/tests/integration/features/chat/poll.feature +++ b/tests/integration/features/chat/poll.feature @@ -589,3 +589,56 @@ Feature: chat/poll | options | ["Empty question is not","allowed either"] | | resultMode | public | | maxVotes | unlimited | + + Scenario: Deleting a user neutralizes their details + Given user "participant1" creates room "room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" adds user "participant2" to room "room" with 200 (v4) + And user "participant2" creates a poll in room "room" with 201 + | question | What is the question? | + | options | ["Where are you?","How much is the fish?"] | + | resultMode | public | + | maxVotes | unlimited | + And user "participant2" votes for options "[0]" on poll "What is the question?" in room "room" with 200 + | id | POLL_ID(What is the question?) | + | question | What is the question? | + | options | ["Where are you?","How much is the fish?"] | + | votes | {"option-0":1} | + | numVoters | 1 | + | resultMode | public | + | maxVotes | unlimited | + | actorType | users | + | actorId | participant2 | + | actorDisplayName | participant2-displayname | + | status | open | + | votedSelf | [0] | + And user "participant2" closes poll "What is the question?" in room "room" with 200 + | id | POLL_ID(What is the question?) | + | question | What is the question? | + | options | ["Where are you?","How much is the fish?"] | + | votes | {"option-0":1} | + | numVoters | 1 | + | resultMode | public | + | maxVotes | unlimited | + | actorType | users | + | actorId | participant2 | + | actorDisplayName | participant2-displayname | + | status | closed | + | votedSelf | [0] | + | details | [{"actorType":"users","actorId":"participant2","actorDisplayName":"participant2-displayname","optionId":0}] | + When user "participant2" is deleted + Then user "participant1" sees poll "What is the question?" in room "room" with 200 + | id | POLL_ID(What is the question?) | + | question | What is the question? | + | options | ["Where are you?","How much is the fish?"] | + | votes | {"option-0":1} | + | numVoters | 1 | + | resultMode | public | + | maxVotes | unlimited | + | actorType | deleted_users | + | actorId | deleted_users | + | actorDisplayName | | + | status | closed | + | votedSelf | [] | + | details | [{"actorType":"deleted_users","actorId":"deleted_users","actorDisplayName":"","optionId":0}] | From 44b2d063993a43866ec7e930fb38452860dee363 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 14 Sep 2022 08:40:58 +0200 Subject: [PATCH 2/3] Fix display name and avatar of deleted users in the poll details Signed-off-by: Joas Schilling --- src/components/AvatarWrapper/AvatarWrapperSmall.vue | 10 +++++++++- .../Message/MessagePart/PollVotersDetails.vue | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/AvatarWrapper/AvatarWrapperSmall.vue b/src/components/AvatarWrapper/AvatarWrapperSmall.vue index 952450dd8e1..9c88832ad24 100644 --- a/src/components/AvatarWrapper/AvatarWrapperSmall.vue +++ b/src/components/AvatarWrapper/AvatarWrapperSmall.vue @@ -28,6 +28,11 @@
+
+ X +
Date: Wed, 14 Sep 2022 09:01:39 +0200 Subject: [PATCH 3/3] Add a test for deleting user info from reactions as well Signed-off-by: Joas Schilling --- .../features/reaction/react.feature | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration/features/reaction/react.feature b/tests/integration/features/reaction/react.feature index ebd6ef06344..31fbca93a83 100644 --- a/tests/integration/features/reaction/react.feature +++ b/tests/integration/features/reaction/react.feature @@ -164,3 +164,25 @@ Feature: reaction/react And user "participant1" sees the following messages in room "room" with 200 | room | actorType | actorId | actorDisplayName | message | messageParameters | reactions | | room | users | participant1 | participant1-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | [] | + + Scenario: Deleting a user neutralizes their details + Given user "participant1" creates room "room" (v4) + | roomType | 3 | + | roomName | room | + And user "participant1" adds user "participant2" to room "room" with 200 (v4) + And user "participant1" sends message "Message 1" to room "room" with 201 + And user "participant2" react with "👍" on message "Message 1" to room "room" with 201 + | actorType | actorId | actorDisplayName | reaction | + | users | participant2 | participant2-displayname | 👍 | + And user "participant2" react with "👎" on message "Message 1" to room "room" with 201 + | actorType | actorId | actorDisplayName | reaction | + | users | participant2 | participant2-displayname | 👎 | + | users | participant2 | participant2-displayname | 👍 | + When user "participant2" is deleted + And user "participant1" retrieve reactions "👎" of message "Message 1" in room "room" with 200 + | actorType | actorId | actorDisplayName | reaction | + | deleted_users | deleted_users | | 👎 | + And user "participant1" retrieve reactions "all" of message "Message 1" in room "room" with 200 + | actorType | actorId | actorDisplayName | reaction | + | deleted_users | deleted_users | | 👎 | + | deleted_users | deleted_users | | 👍 |