fix(request-actions): match group add/invite flags by UID and add regression tests

This commit is contained in:
stla committed 2026-05-18 07:03:45 +00:00
1 parent 7a2de230bf
commit b99f5c0bf1
2 files changed
+77 -1

No files matched your search

@@ -9,11 +9,20 @@ export async function handleGroupAddRequest(
// flag format: "add:groupId:uid" or "invite:groupId:uid" (from event-converter)
const parts = flag.split(':');
if (parts.length < 3) throw new Error('invalid group request flag');
const requestType = parts[0];
const groupId = parseInt(parts[1], 10);
const targetUid = parts.slice(2).join(':');
if (!groupId) throw new Error('invalid group_id in flag');
if (!targetUid) throw new Error('invalid request target in flag');
const requests = await bridge.fetchGroupRequests();
const matching = requests.find(r => r.groupId === groupId);
const matching = requests.find((r) => {
if (r.groupId !== groupId) return false;
if (requestType === 'add') return r.targetUid === targetUid;
if (requestType === 'invite') return r.invitorUid === targetUid;
return false;
}) || requests.find(r => r.groupId === groupId);
if (!matching) {
throw new Error('matching group request not found');
}