fix: use canonical identity for federated friend/request dedup
The socialStore WS-driven handlers (addFriendFromAccepted, addIncomingRequest, removeFriendLocally, removeRequestById, updateFriendPresence) used instance-local id:origin composite keys for deduplication. When the client is connected to multiple instances, both fire WS events for the same federated user with different local IDs, bypassing the dedup and creating duplicate entries. Switch all handlers to use homeUserId??id (canonical identity), matching the pattern loadFriends/loadRequests already use. Also replace the loadRequests() re-fetch in updateFriendRequest with optimistic canonical removal to avoid racing S2S relay propagation.
This commit is contained in:
@@ -736,7 +736,7 @@ function handleEvent(origin: string, event: ServerEvent): void {
|
||||
|
||||
case 'friend_request_cancelled': {
|
||||
const { removeRequestById } = useSocialStore.getState();
|
||||
removeRequestById(event.requestId, origin);
|
||||
removeRequestById(event.requestId, origin, event.userId);
|
||||
import('../stores/discoverStore').then(({ useDiscoverStore }) => {
|
||||
useDiscoverStore.getState().updateRelationship(event.userId, origin, 'none');
|
||||
});
|
||||
@@ -745,7 +745,7 @@ function handleEvent(origin: string, event: ServerEvent): void {
|
||||
|
||||
case 'friend_request_declined': {
|
||||
const { removeRequestById } = useSocialStore.getState();
|
||||
removeRequestById(event.requestId, origin);
|
||||
removeRequestById(event.requestId, origin, event.userId);
|
||||
import('../stores/discoverStore').then(({ useDiscoverStore }) => {
|
||||
useDiscoverStore.getState().updateRelationship(event.userId, origin, 'none');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user