fix(social): friend_request_sent local broadcast must carry target profile

The local branch was reusing friendRequestPayload (built for
friend_request_received with user=sender) for the sender-side
friend_request_sent broadcast. Tab B on the sender would render
the sender's own avatar where the target's should appear.
Match the federated branch — sent broadcast carries target.
This commit is contained in:
Jannis Braun
2026-04-25 22:18:47 +02:00
parent 1ad1fd1b0c
commit d88d369a82
3 changed files with 28 additions and 11 deletions
+14 -4
View File
@@ -88,8 +88,8 @@ async function handleLocalFriendRequest(
createdAt: now,
}).run();
// Broadcast friend_request_received to the target user
const friendRequestPayload: FriendRequest = {
// Broadcast to the target: they need to know who sent the request (sender profile).
const receivedPayload: FriendRequest = {
id,
fromId: request.userId,
toId: targetUser.id,
@@ -98,14 +98,24 @@ async function handleLocalFriendRequest(
user: sanitizeUser(sender),
};
// Broadcast to the sender's other tabs: they need to know who they added (target profile).
const sentPayload: FriendRequest = {
id,
fromId: request.userId,
toId: targetUser.id,
status: 'pending',
createdAt: now,
user: sanitizeUser(targetUser),
};
connectionManager.sendToUser(targetUser.id, {
type: 'friend_request_received',
request: friendRequestPayload,
request: receivedPayload,
});
connectionManager.sendToUser(request.userId, {
type: 'friend_request_sent',
request: friendRequestPayload,
request: sentPayload,
});
// Federation relay: notify the target user's home instance