fix p2p conversation avatars

This commit is contained in:
richjohnrambo
2026-10-14 16:09:38 +08:00
parent 8a26a4ccf9
commit 361e23b9ec
3 changed files with 47 additions and 2 deletions
+20
View File
@@ -0,0 +1,20 @@
export interface FriendAvatarSource {
user_id: string;
topic?: string;
avatar_file_id?: string;
}
/**
* P2P contacts are keyed by their `p2p...` topic after the first subscription,
* while the friends API identifies the same person with a `usr...` user ID.
* Keep both aliases so avatars work during both the initial and established
* conversation states.
*/
export function friendAvatarLookup(friends: FriendAvatarSource[] = []) {
const avatars = new Map<string, string | undefined>();
for (const friend of friends) {
if (friend.user_id) avatars.set(friend.user_id, friend.avatar_file_id);
if (friend.topic) avatars.set(friend.topic, friend.avatar_file_id);
}
return avatars;
}