fix(onebot): approve group requests from the filtered inbox too (#197)
set_group_add_request could fail with "matching group request not found" for a request SnowLuma had itself just reported. handleGroupAddRequest only fetched the main inbox (0x10C8 subCommand 1); a spam-filtered join/invite lives in the filtered inbox (subCommand 2) and was never searched, so its flag couldn't be resolved to a sequence. Fetch both inboxes and search the union. Each request keeps the `filtered` flag its approval subCommand needs, so a filtered request is approved through subCommand 2. A failing inbox fetch degrades to the other instead of aborting. Regular MSF invite pushes don't carry the approval msgseq (only the private-card path does, #125), so the fetch is the only source. Regression tests: filtered-only request is found + approved via subCommand 2; "not found" only when neither inbox has it.
This commit is contained in:
2 files changed
+41
-1
No files matched your search
@@ -27,7 +27,18 @@ export async function handleGroupAddRequest(
|
||||
}
|
||||
}
|
||||
|
||||
const requests = await bridge.apis.contacts.fetchGroupRequests();
|
||||
// A join/invite request lands in either the main inbox (0x10c8 subCommand 1)
|
||||
// or the spam-filtered one (subCommand 2). The old code only fetched the main
|
||||
// inbox, so a filtered request that SnowLuma had already reported to the
|
||||
// client couldn't be approved through its own flag — "matching group request
|
||||
// not found" (#197). Search both; each request keeps the `filtered` flag its
|
||||
// inbox needs for the approval subCommand. One inbox failing degrades to the
|
||||
// other rather than aborting.
|
||||
const [mainInbox, filteredInbox] = await Promise.all([
|
||||
bridge.apis.contacts.fetchGroupRequests(false).catch(() => []),
|
||||
bridge.apis.contacts.fetchGroupRequests(true).catch(() => []),
|
||||
]);
|
||||
const requests = [...mainInbox, ...filteredInbox];
|
||||
const matching = requests.find((r) => {
|
||||
if (r.groupId !== groupId) return false;
|
||||
if (requestType === 'add') return r.targetUid === targetUid;
|
||||
|
||||
Reference in new issue
Block a user