diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2022-04-19 10:19:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-19 10:19:48 +0200 |
commit | 1451f35eb0f72b1888078c505dbf61a8a6df8901 (patch) | |
tree | 120eaaba4f94b3e3e080273f7bf8597cdaefab86 | |
parent | fc01aed196572dc0ef172f38702bc48b6aea451c (diff) | |
parent | 20a62f4f18436dde3d3688579966a0847698579a (diff) |
Merge pull request #7130 from nextcloud/feature/7009/retain-files-after-leaving-conversation
Remove event to delete shares when user leave of room
-rw-r--r-- | lib/Share/RoomShareProvider.php | 22 | ||||
-rw-r--r-- | tests/integration/features/sharing-2/hooks.feature | 40 |
2 files changed, 20 insertions, 42 deletions
diff --git a/lib/Share/RoomShareProvider.php b/lib/Share/RoomShareProvider.php index 287477884..28dbfef15 100644 --- a/lib/Share/RoomShareProvider.php +++ b/lib/Share/RoomShareProvider.php @@ -29,8 +29,6 @@ declare(strict_types=1); namespace OCA\Talk\Share; use OC\Files\Cache\Cache; -use OCA\Talk\Events\ParticipantEvent; -use OCA\Talk\Events\RemoveUserEvent; use OCA\Talk\Events\RoomEvent; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; @@ -106,26 +104,6 @@ class RoomShareProvider implements IShareProvider { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function (ParticipantEvent $event): void { - $room = $event->getRoom(); - - if ($event->getParticipant()->getAttendee()->getParticipantType() === Participant::USER_SELF_JOINED) { - /** @var self $roomShareProvider */ - $roomShareProvider = \OC::$server->get(self::class); - $roomShareProvider->deleteInRoom($room->getToken(), $event->getParticipant()->getAttendee()->getActorId()); - } - }; - $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DISCONNECT, $listener); - - $listener = static function (RemoveUserEvent $event): void { - $room = $event->getRoom(); - - /** @var self $roomShareProvider */ - $roomShareProvider = \OC::$server->get(self::class); - $roomShareProvider->deleteInRoom($room->getToken(), $event->getUser()->getUID()); - }; - $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, $listener); - $listener = static function (RoomEvent $event): void { $room = $event->getRoom(); diff --git a/tests/integration/features/sharing-2/hooks.feature b/tests/integration/features/sharing-2/hooks.feature index 9bd9cbe15..08e490a5f 100644 --- a/tests/integration/features/sharing-2/hooks.feature +++ b/tests/integration/features/sharing-2/hooks.feature @@ -57,9 +57,9 @@ Feature: hooks And user "participant2" shares "welcome.txt" with room "group room" with OCS 100 When user "participant1" removes "participant2" from room "group room" with 200 (v4) Then user "participant1" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" And user "participant2" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" Scenario: remove herself from group room after sharing a file Given user "participant1" creates room "group room" (v4) @@ -69,9 +69,9 @@ Feature: hooks And user "participant2" shares "welcome.txt" with room "group room" with OCS 100 When user "participant2" removes themselves from room "group room" with 200 (v4) Then user "participant1" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" And user "participant2" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" Scenario: leave group room after sharing a file Given user "participant1" creates room "group room" (v4) @@ -145,9 +145,9 @@ Feature: hooks And user "participant2" shares "welcome.txt" with room "public room" with OCS 100 When user "participant2" leaves room "public room" with 200 (v4) Then user "participant1" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" And user "participant2" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" Scenario: remove sharer from group room with other shares after sharing a file Given user "participant1" creates room "group room" (v4) @@ -160,9 +160,9 @@ Feature: hooks And user "participant2" shares "welcome.txt" with room "group room" with OCS 100 When user "participant1" removes "participant2" from room "group room" with 200 (v4) Then user "participant1" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" And user "participant2" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" And user "participant1" gets all shares And the list of returned shares has 1 shares And share 0 is returned with @@ -191,9 +191,9 @@ Feature: hooks And user "participant3" accepts last share When user "participant1" removes "participant2" from room "group room" with 200 (v4) Then user "participant1" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" And user "participant1" gets all shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares And user "participant2" gets last share And share is returned with | uid_owner | participant1 | @@ -209,7 +209,7 @@ Feature: hooks | share_with_displayname | participant3-displayname | | share_type | 0 | And user "participant2" gets all shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares And user "participant3" gets last share And share is returned with | uid_owner | participant1 | @@ -455,9 +455,9 @@ Feature: hooks And user "participant2" removes "participant1" from room "group room" with 200 (v4) When user "participant2" adds user "participant1" to room "group room" with 200 (v4) Then user "participant1" gets all shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares And user "participant2" gets all received shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares Scenario: add sharer again to group room after sharing a file and the sharer removed herself from the room Given user "participant2" creates room "group room" (v4) @@ -468,9 +468,9 @@ Feature: hooks And user "participant1" removes themselves from room "group room" with 200 (v4) When user "participant2" adds user "participant1" to room "group room" with 200 (v4) Then user "participant1" gets all shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares And user "participant2" gets all received shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares Scenario: join public room again after sharing a file and the sharer left the room Given user "participant2" creates room "public room" (v4) @@ -481,9 +481,9 @@ Feature: hooks And user "participant1" leaves room "public room" with 200 (v4) When user "participant1" joins room "public room" with 200 (v4) Then user "participant1" gets all shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares And user "participant2" gets all received shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares @@ -498,9 +498,9 @@ Feature: hooks And user "participant1" removes "participant2" from room "group room" with 200 (v4) When user "participant1" adds user "participant2" to room "group room" with 200 (v4) Then user "participant1" gets last share - And the OCS status code should be "404" + And the OCS status code should be "100" And user "participant1" gets all shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares And user "participant2" gets last share And share is returned with | uid_owner | participant1 | @@ -516,7 +516,7 @@ Feature: hooks | share_with_displayname | participant3-displayname | | share_type | 0 | And user "participant2" gets all shares - And the list of returned shares has 0 shares + And the list of returned shares has 1 shares And user "participant3" gets last share And share is returned with | uid_owner | participant1 | |