mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 18:31:10 +00:00
fix(hooks): add isGroup and groupId to message:sent context
Adds group context fields to MessageSentHookContext so hooks can correlate sent events with received events for the same conversation. Previously, message:received included isGroup/groupId but message:sent did not, forcing hooks to use mismatched identifiers (e.g. groupId vs numeric chat ID) when tracking conversations. Fields are derived from MsgContext in dispatch-from-config and threaded through route-reply and deliver via the mirror parameter. Addresses feedback from matskevich (production user, 550+ events) reported on PR #6797.
This commit is contained in:
committed by
Peter Steinberger
parent
7ad6a04058
commit
b5102ba4f9
@@ -220,6 +220,10 @@ type DeliverOutboundPayloadsCoreParams = {
|
||||
agentId?: string;
|
||||
text?: string;
|
||||
mediaUrls?: string[];
|
||||
/** Whether this message is being sent in a group/channel context */
|
||||
isGroup?: boolean;
|
||||
/** Group or channel identifier for correlation with received events */
|
||||
groupId?: string;
|
||||
};
|
||||
silent?: boolean;
|
||||
};
|
||||
@@ -478,6 +482,8 @@ async function deliverOutboundPayloadsCore(
|
||||
});
|
||||
const hookRunner = getGlobalHookRunner();
|
||||
const sessionKeyForInternalHooks = params.mirror?.sessionKey ?? params.session?.key;
|
||||
const mirrorIsGroup = params.mirror?.isGroup;
|
||||
const mirrorGroupId = params.mirror?.groupId;
|
||||
if (
|
||||
hookRunner?.hasHooks("message_sent") &&
|
||||
params.session?.agentId &&
|
||||
@@ -534,6 +540,8 @@ async function deliverOutboundPayloadsCore(
|
||||
accountId: accountId ?? undefined,
|
||||
conversationId: to,
|
||||
messageId: params.messageId,
|
||||
...(mirrorIsGroup != null ? { isGroup: mirrorIsGroup } : {}),
|
||||
...(mirrorGroupId ? { groupId: mirrorGroupId } : {}),
|
||||
}),
|
||||
).catch(() => {});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user