fix(RelationshipNotifier): Ignore user-actioned friend requests (#1390)

This commit is contained in:
dolfies 2023-07-07 20:37:32 -04:00 committed by GitHub
parent cde8074f44
commit 2db0e71e5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

@ -50,7 +50,7 @@ export async function onRelationshipRemove({ relationship: { type, id } }: Relat
() => openUserProfile(user.id) () => openUserProfile(user.id)
); );
break; break;
case RelationshipType.FRIEND_REQUEST: case RelationshipType.INCOMING_REQUEST:
if (settings.store.friendRequestCancels) if (settings.store.friendRequestCancels)
notify( notify(
`A friend request from ${getUniqueUsername(user)} has been removed.`, `A friend request from ${getUniqueUsername(user)} has been removed.`,

@ -58,5 +58,7 @@ export const enum ChannelType {
export const enum RelationshipType { export const enum RelationshipType {
FRIEND = 1, FRIEND = 1,
FRIEND_REQUEST = 3, BLOCKED = 2,
INCOMING_REQUEST = 3,
OUTGOING_REQUEST = 4,
} }

@ -80,7 +80,10 @@ export async function syncAndRunChecks() {
if (settings.store.friendRequestCancels && oldFriends?.requests?.length) { if (settings.store.friendRequestCancels && oldFriends?.requests?.length) {
for (const id of oldFriends.requests) { for (const id of oldFriends.requests) {
if (friends.requests.includes(id)) continue; if (
friends.requests.includes(id) ||
[RelationshipType.FRIEND, RelationshipType.BLOCKED, RelationshipType.OUTGOING_REQUEST].includes(RelationshipStore.getRelationshipType(id))
) continue;
const user = await UserUtils.fetchUser(id).catch(() => void 0); const user = await UserUtils.fetchUser(id).catch(() => void 0);
if (user) if (user)
@ -164,7 +167,7 @@ export async function syncFriends() {
case RelationshipType.FRIEND: case RelationshipType.FRIEND:
friends.friends.push(id); friends.friends.push(id);
break; break;
case RelationshipType.FRIEND_REQUEST: case RelationshipType.INCOMING_REQUEST:
friends.requests.push(id); friends.requests.push(id);
break; break;
} }