-
Notifications
You must be signed in to change notification settings - Fork 508
Propagate permission changes to federated servers #12979
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
883998e
fix: Propagate permission changes of federated users to their servers
danxuliu 12290ea
refactor: Include additional context in room permission change events
danxuliu ceb9aef
fix: Propagate permission changes of conversations to federated servers
danxuliu f0d8036
fix: Propagate permissions to new federated conversations
danxuliu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
fix: Propagate permission changes of federated users to their servers
The frontend gets the permission for the current participant from the room data (as guest users can not get it from the participant list). However, permission changes were not propagated to federated servers, so the frontend of federated users always assumed that the user had the default permissions. Signed-off-by: Daniel Calviño Sánchez <[email protected]>
- Loading branch information
commit 883998e2443d754732cb445e62f389ee74d26786
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
lib/Federation/Proxy/TalkV1/Notifier/ParticipantModifiedListener.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Federation\Proxy\TalkV1\Notifier; | ||
|
|
||
| use OCA\Talk\Events\AAttendeeRemovedEvent; | ||
| use OCA\Talk\Events\AParticipantModifiedEvent; | ||
| use OCA\Talk\Events\ParticipantModifiedEvent; | ||
| use OCA\Talk\Federation\BackendNotifier; | ||
| use OCA\Talk\Model\Attendee; | ||
| use OCA\Talk\Participant; | ||
| use OCA\Talk\Service\ParticipantService; | ||
| use OCP\EventDispatcher\Event; | ||
| use OCP\EventDispatcher\IEventListener; | ||
| use OCP\Federation\ICloudId; | ||
| use OCP\Federation\ICloudIdManager; | ||
|
|
||
| /** | ||
| * @template-implements IEventListener<Event> | ||
| */ | ||
| class ParticipantModifiedListener implements IEventListener { | ||
| public function __construct( | ||
| protected BackendNotifier $backendNotifier, | ||
| protected ParticipantService $participantService, | ||
| protected ICloudIdManager $cloudIdManager, | ||
| ) { | ||
| } | ||
|
|
||
| public function handle(Event $event): void { | ||
| if (!$event instanceof ParticipantModifiedEvent) { | ||
| return; | ||
| } | ||
|
|
||
| if (!in_array($event->getProperty(), [ | ||
| AParticipantModifiedEvent::PROPERTY_PERMISSIONS, | ||
| ], true)) { | ||
| return; | ||
| } | ||
|
|
||
| $participants = $this->participantService->getParticipantsByActorType($event->getRoom(), Attendee::ACTOR_FEDERATED_USERS); | ||
| foreach ($participants as $participant) { | ||
| $cloudId = $this->cloudIdManager->resolveCloudId($participant->getAttendee()->getActorId()); | ||
|
|
||
| $success = $this->notifyParticipantModified($cloudId, $participant, $event); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should only be sent to the instance of the user that is modified. |
||
|
|
||
| if ($success === null) { | ||
| $this->participantService->removeAttendee($event->getRoom(), $participant, AAttendeeRemovedEvent::REASON_LEFT); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private function notifyParticipantModified(ICloudId $cloudId, Participant $participant, AParticipantModifiedEvent $event) { | ||
| return $this->backendNotifier->sendParticipantModifiedUpdate( | ||
| $cloudId->getRemote(), | ||
| $participant->getAttendee()->getId(), | ||
| $participant->getAttendee()->getAccessToken(), | ||
| $event->getRoom()->getToken(), | ||
| $event->getProperty(), | ||
| $event->getNewValue(), | ||
| $event->getOldValue(), | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| Feature: federation/permissions | ||
|
|
||
| Background: | ||
| Given user "participant1" exists | ||
| And user "participant2" exists | ||
| And the following "spreed" app config is set | ||
| | federation_enabled | yes | | ||
|
|
||
| Scenario: set participant permissions | ||
| Given user "participant1" creates room "room" (v4) | ||
| | roomType | 2 | | ||
| | roomName | room name | | ||
| And user "participant1" adds federated_user "participant2" to room "room" with 200 (v4) | ||
| And user "participant2" has the following invitations (v1) | ||
| | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | | ||
| | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | | ||
| And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1) | ||
| | id | name | type | remoteServer | remoteToken | | ||
| | LOCAL::room | room name | 2 | LOCAL | room | | ||
| When user "participant1" sets permissions for "participant2@{$LOCAL_REMOTE_URL}" in room "room" to "S" with 200 (v4) | ||
| Then user "participant2" is participant of room "LOCAL::room" (v4) | ||
| | permissions | | ||
| | CS | |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this always updates the permissions of the recipient, independent of which users permissions were actually modified? :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event includes the final permissions, no matter if they were set, added or removed, so the effect should be the same, no? 🤔