fix: Do not use invitor avatar_url for room

When user A invites user B to
a group chat, the avatar getter
should not return the
avatar of the inviting user A.
This is not intuitive. A client might
decide to do so but IMO it makes
no sense to do this by default.
If the
room is a DM invite, user A's
avatar is already used in the
code block before.
This commit is contained in:
krille-chan 2024-04-07 17:10:21 +02:00 committed by Krille
parent bd52205ae9
commit d0b1d4a651
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
1 changed files with 3 additions and 9 deletions

View File

@ -288,8 +288,9 @@ class Room {
/// The avatar of the room if set by a participant. /// The avatar of the room if set by a participant.
Uri? get avatar { Uri? get avatar {
final avatarUrl = getState(EventTypes.RoomAvatar)?.content['url']; final avatarUrl =
if (avatarUrl is String) { getState(EventTypes.RoomAvatar)?.content.tryGet<String>('url');
if (avatarUrl != null) {
return Uri.tryParse(avatarUrl); return Uri.tryParse(avatarUrl);
} }
@ -306,13 +307,6 @@ class Room {
return unsafeGetUserFromMemoryOrFallback(user).avatarUrl; return unsafeGetUserFromMemoryOrFallback(user).avatarUrl;
} }
} }
if (membership == Membership.invite) {
final userID = client.userID;
if (userID == null) return null;
return getState(EventTypes.RoomMember, userID)
?.senderFromMemoryOrFallback
.avatarUrl;
}
return null; return null;
} }