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

Matrix: use per-room nicknames #1541

Closed
wants to merge 1 commit into from

Conversation

nightmared
Copy link
Contributor

@codeclimate
Copy link

codeclimate bot commented Jul 9, 2021

Code Climate has analyzed commit 23e785d and detected 0 issues on this pull request.

View more on Code Climate.

@42wim
Copy link
Owner

42wim commented Jul 31, 2021

Not sure how this works? There's only one global displayname?
https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-profile-userid-displayname

Seems like the per-room displayname is still being worked on - element-hq/element-meta#499 / matrix-org/matrix-spec-proposals#3189

@nightmared
Copy link
Contributor Author

nightmared commented Jul 31, 2021

In element you can already update your per-room nick with the commande /myroomnick (which as far as I understand it only send the nickname change in the affected room, the other rooms keep the current nickname).

@42wim
Copy link
Owner

42wim commented Jul 31, 2021

Sure, but the API call here is fetching the global nick mc.GetDisplayName, there is no way to fetch the nick per room using the matrix API ?
Or am I missing something?

@nightmared
Copy link
Contributor Author

Hmm yeah I'm not really sure, I guess this is fixed by getting the state when syncing:

GET /_matrix/client/r0/sync

Note: This endpoint supports lazy-loading. See Filtering for more information. Lazy-loading members is only supported on a StateFilter for this endpoint. When lazy-loading is enabled, servers MUST include the syncing user's own membership event when they join a room, or when the full state of rooms is requested, to aid discovering the user's avatar & displayname.

I will have to check that it also works when display names are changed while matterbridge is stopped.

@nightmared
Copy link
Contributor Author

nightmared commented Jul 31, 2021

So, from what I understand, a server send the update when a user changes its displayname (as per https://matrix.org/docs/spec/client_server/r0.6.1#events-on-change-of-profile-information), and the server also sends that information when the bridge starts, sending all the events since that last MarkRead() (I guess that's the point where it starst sending events again). And we use that information in handleMemberChange to update the displayname for the given room (in which case we do not use the dedicated matrix APi call).

@42wim
Copy link
Owner

42wim commented Aug 1, 2021

For the current code (and your PR) this means that there's a 10 minute delay before the nickname also changes in the other rooms because we remove the cache every 10 minutes. And we'll ask for the nickname again (using the matrix API call)

if now.Sub(NicknameCacheIter.lastUpdated) > 10*time.Minute {
toDelete[channelIDIter] = mxidIter
}

So I don't think this fixes the issue ?

@nightmared
Copy link
Contributor Author

nightmared commented Aug 1, 2021

Oh yeah, I haven't tried this patch over sessions running long enough to hit that case. You're right, I will have to rethink this code. I'm not sure yet this is simple to do in matterbridge because there is no data persistence across restarts.

@nightmared
Copy link
Contributor Author

I'm not currently working on this, so I'm gonna close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sometimes you can see events from before you joined a room, with just the senders shown
2 participants