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

Fix avatars in federated calls #12863

Merged
merged 3 commits into from
Aug 1, 2024
Merged

Conversation

danxuliu
Copy link
Member

@danxuliu danxuliu commented Jul 31, 2024

Follow up to #12668

Although the userId property in the participants->update signaling message, which is used by clients to know the participants in a call, was set to the cloud ID for federated participants this was not enough to identify a federated user, as it was not possible to know for sure the actor type only based on the user ID (as a local user could have a user ID that resembled a cloud ID, so looking for @ remote would not be reliable).

Due to that now the participants->update signaling messages explicitly provide the actorType and actorId of each participant in the message (and userId is again provided only for regular users like it was always done). Knowing the actor type and id clients can now request the avatar from the right endpoint and with the right data.

In the WebUI now actorType and actorId take precedence over userId when identifying a participant in VideoView, which automatically causes AvatarWrapper to use the right endpoint (once the type and id are converted, see below).

Converting actor type and id

Conversion of actorType and actorId in participants->update signaling messages will be automatically done by the external signaling server, so clients just need to use the received values as is (so the client of a federated user will see actorType: users for users in its own server and actorType: federated_users for users in the host server, in both cases with actorId adjusted as needed, just like when getting the participants from the API). However, this might become relevant again once/if federated calls are implemented in the internal signaling server, so leaving the section below for reference.

There is an important detail to keep in mind, though. The actor type and id in the signaling messages are from the point of view of the host Nextcloud server. Therefore, the client of a federated user would need to convert the actor type and id between local users and federated users, similarly to [how a federated Nextcloud server does it](https://github.com/nextcloud/spreed/blob/897c069d4ae80a5500e6dd0ac735bf3ebbc9e33a/lib/Federation/Proxy/TalkV1/UserConverter.php#L38-L53) when returning the list of participants (as a local user from the point of view of the host is a federated user from the point of view of the federated server, and a federated user from a specific remote server from the point of view of the host is a local user from the point of view of that specific remote server).

Note, however, that in order to get the avatars only converting from local users to federated users is strictly needed. Avatars can be got using two different API endpoints, one that accepts a user ID and another one that accepts a cloud ID; in the first case only avatars for local users are returned, while in the second case avatars are returned for both local and remote users. Therefore, if a federated user is not converted to a local user the proxy endpoint will be used, but it will correctly return the avatar for the local user. Nevertheless it might be better to do the conversion anyway for any other future use of the actor type and id.

How to test

  • Set up two Nextcloud servers with external signaling servers and federation
    • External signaling servers require support for converting the actorType and actorId in participants->update signaling messages
  • Create a conversation in Nextcloud server A
  • Add two users from Nextcloud server B
  • In a private window, log in Nextcloud server B with one user
  • Accept the invitation and join the conversation
  • In another browser/device, log in Nextcloud server B with the other user
  • Accept the invitation and join the conversation
  • Start the call and join with all users

Result with this pull request

The right avatars are shown for all users

Result without this pull request

Broken avatars are shown for all users (except oneself)

When the Nextcloud server notifies the signaling server about updates in
the participants it provides a list of properties about each participant
that will be relayed to the clients in the "participants->update"
signaling messages. When federated users were added to the participants
whose properties were relayed the "userId", which until then was set
only for regular users, was set too to the actor id for federated
participants. However, this approach was lacking, as it was not possible
for clients to really know from the "userId" property if the participant
was federated or not or, in a more general way, its actor type.

Due to that the "userId" is again set only for regular users for
backwards compatibility, and the "actorType" and "actorId" properties
are added to the data of each participant included in the
"participants->update" signaling message.

For consistency, "actorType" and "actorId" is also set in the equivalent
message of the internal signaling server.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
The actor type and id are now set in "CallParticipantModel" when a
participant joins the call, similarly to how it was done for the user
ID.

Actor type and id now take precedence over the user ID in the
"VideoView" component, so "AvatarWrapper" now uses the correct source
for participant avatars (as long as the actor type and id are correct,
which in federated conversations require a conversion from the values
sent by the host server and the values used by the federated server).

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@danxuliu danxuliu force-pushed the fix-avatars-in-federated-calls branch from 3c72fcf to 4203f4d Compare August 1, 2024 11:35
@@ -293,6 +293,7 @@ function usersChanged(signaling, newUsers, disconnectedSessionIds) {
webRtc: webrtc,
})
}
callParticipantModel.setActor(user.actorType, user.actorId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

desktop client goes 💥 when speaking to a 19 server?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attributes would be simply undefined, which would not change the previous behaviour nor break anything, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, no PHP style Undefined key X error. fine by me then

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@danxuliu danxuliu force-pushed the fix-avatars-in-federated-calls branch from d570cd5 to 0264d3d Compare August 1, 2024 13:01
@danxuliu danxuliu marked this pull request as ready for review August 1, 2024 13:02
@danxuliu
Copy link
Member Author

danxuliu commented Aug 1, 2024

The conversion between actorTypeand actorId was dropped, as @fancycode will be doing that in the signaling server. Thanks a lot!

Therefore while avatars are still broken in the current state this pull request prepares the WebUI to correctly shown them once the signaling server is updated :-)

@nickvergessen nickvergessen merged commit ee0f880 into main Aug 1, 2024
69 checks passed
@nickvergessen nickvergessen deleted the fix-avatars-in-federated-calls branch August 1, 2024 13:27
fancycode added a commit to strukturag/nextcloud-spreed-signaling that referenced this pull request Aug 5, 2024
@fancycode
Copy link
Member

The conversion between actorTypeand actorId was dropped, as @fancycode will be doing that in the signaling server. Thanks a lot!

Done in strukturag/nextcloud-spreed-signaling@1a823ef

@danxuliu
Copy link
Member Author

danxuliu commented Aug 6, 2024

The conversion between actorTypeand actorId was dropped, as @fancycode will be doing that in the signaling server. Thanks a lot!

Done in strukturag/nextcloud-spreed-signaling@1a823ef

Tested and works 👍 Thanks!

fancycode added a commit to strukturag/nextcloud-spreed-signaling that referenced this pull request Aug 6, 2024
fancycode added a commit to strukturag/nextcloud-spreed-signaling that referenced this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants