Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Don't rely on room members to query power levels #2145

Merged
merged 1 commit into from
Sep 5, 2018

Conversation

bwindels
Copy link
Contributor

@bwindels bwindels commented Sep 3, 2018

Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

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

Hmm - isn't the server at fault if it hasn't sent us our own member event? If so, briefly telling you you can't send a message feels like a reasonable failure mode here, especially given this will still sometimes be wrong (eg. if you're an admin and only admins can post).

const me = room.getMember(MatrixClientPeg.get().getUserId());
if (me) {
return room.currentState.maySendMessage(me.userId);
} else if(room.getMyMembership() === 'join') {
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: consistent spacing

@ara4n
Copy link
Member

ara4n commented Sep 4, 2018

no, we've concluded that for LL the server is entitled not to send you your own membership event (which is after all redundant and a waste of bandwidth).

@bwindels
Copy link
Contributor Author

bwindels commented Sep 4, 2018

Actually, we have all the information we need in the power levels state event. We just shouldn't rely on having a member object. My bad, I'll change it.

as it is always are of the syncing user's membership
in case of lazy loading members
@bwindels
Copy link
Contributor Author

bwindels commented Sep 4, 2018

ready for another look

@bwindels bwindels changed the title Query user default powerlevels before own member is loaded Don't rely on room members to query power levels Sep 4, 2018
@dbkr
Copy link
Member

dbkr commented Sep 4, 2018

How do you know your own display name and avatar URL in that room if you don't have your own membership event?

@bwindels
Copy link
Contributor Author

bwindels commented Sep 5, 2018

@dbkr With #2132 we're now waiting for the members to load before showing the own avatar in the composer. I'm unsure where we currently display the own display name. This isn't great as it is, as the layout of the composer without the avatar rendered is currently a bit broken (everything moves to the left). We could easily solve this though by reverting to User, or even keep track of our own a profile info.

I'll make a task to improve this experience, but is probably independent of this PR.

@bwindels
Copy link
Contributor Author

bwindels commented Sep 5, 2018

Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

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

We would need the user's display name if they send a message in the room in order to display the local-echo event in the timeline until the member event arrives (we could fall back to their profile info but the global profile isn't necessarily the same as the profile in a given room).

Anyway, this lgtm.

@bwindels
Copy link
Contributor Author

bwindels commented Sep 5, 2018

Right, as it stands this will fallback to a fake sentinel just containing the userid, like for any user ...

Never mind, not sure about the local echo. Will check.

@bwindels bwindels merged commit 50de22f into develop Sep 5, 2018
@bwindels bwindels deleted the bwindels/fixllroompermission branch September 5, 2018 11:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants