mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-10 20:17:32 +01:00
look for displayname/avatar in prev content as well
as synapse doesn't set them on content for leave memberships this caused these props to be removed in storage
This commit is contained in:
parent
bd9cb5aae5
commit
34ec96c1b8
@ -27,21 +27,33 @@ export class RoomMember {
|
|||||||
if (typeof userId !== "string") {
|
if (typeof userId !== "string") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return this._fromMemberEventContent(roomId, userId, memberEvent.content);
|
const content = memberEvent.content;
|
||||||
|
const prevContent = memberEvent.unsigned?.prev_content;
|
||||||
|
const membership = content?.membership;
|
||||||
|
// fall back to prev_content for these as synapse doesn't (always?)
|
||||||
|
// put them on content for "leave" memberships
|
||||||
|
const displayName = content?.displayname || prevContent?.displayname;
|
||||||
|
const avatarUrl = content?.avatar_url || prevContent?.avatar_url;
|
||||||
|
return this._validateAndCreateMember(roomId, userId, membership, displayName, avatarUrl);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Creates a (historical) member from a member event that is the next member event
|
||||||
|
* after the point in time where we need a member for. This will use `prev_content`.
|
||||||
|
*/
|
||||||
static fromReplacingMemberEvent(roomId, memberEvent) {
|
static fromReplacingMemberEvent(roomId, memberEvent) {
|
||||||
const userId = memberEvent && memberEvent.state_key;
|
const userId = memberEvent && memberEvent.state_key;
|
||||||
if (typeof userId !== "string") {
|
if (typeof userId !== "string") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return this._fromMemberEventContent(roomId, userId, memberEvent.prev_content);
|
const content = memberEvent.unsigned?.prev_content
|
||||||
|
return this._validateAndCreateMember(roomId, userId,
|
||||||
|
content?.membership,
|
||||||
|
content?.displayname,
|
||||||
|
content?.avatar_url
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static _fromMemberEventContent(roomId, userId, content) {
|
static _validateAndCreateMember(roomId, userId, membership, displayName, avatarUrl) {
|
||||||
const membership = content?.membership;
|
|
||||||
const avatarUrl = content?.avatar_url;
|
|
||||||
const displayName = content?.displayname;
|
|
||||||
if (typeof membership !== "string") {
|
if (typeof membership !== "string") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user