mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
feat(inbound-meta): expose sender_id in trusted system metadata
Add sender_id (ctx.SenderId) to the openclaw.inbound_meta.v1 payload so agents can reference it for moderation actions (delete, ban, etc.) without relying on user-controlled text fields. message_id and chat_id were already present; sender_id was the missing piece needed for complete group moderation workflows.
This commit is contained in:
committed by
Peter Steinberger
parent
bcab2469de
commit
d4c057f8c1
@@ -32,6 +32,35 @@ describe("buildInboundMetaSystemPrompt", () => {
|
||||
expect(payload["channel"]).toBe("telegram");
|
||||
});
|
||||
|
||||
it("includes sender_id when provided", () => {
|
||||
const prompt = buildInboundMetaSystemPrompt({
|
||||
MessageSid: "456",
|
||||
SenderId: "289522496",
|
||||
OriginatingTo: "telegram:-1001249586642",
|
||||
OriginatingChannel: "telegram",
|
||||
Provider: "telegram",
|
||||
Surface: "telegram",
|
||||
ChatType: "group",
|
||||
} as TemplateContext);
|
||||
|
||||
const payload = parseInboundMetaPayload(prompt);
|
||||
expect(payload["sender_id"]).toBe("289522496");
|
||||
});
|
||||
|
||||
it("omits sender_id when not provided", () => {
|
||||
const prompt = buildInboundMetaSystemPrompt({
|
||||
MessageSid: "789",
|
||||
OriginatingTo: "telegram:5494292670",
|
||||
OriginatingChannel: "telegram",
|
||||
Provider: "telegram",
|
||||
Surface: "telegram",
|
||||
ChatType: "direct",
|
||||
} as TemplateContext);
|
||||
|
||||
const payload = parseInboundMetaPayload(prompt);
|
||||
expect(payload["sender_id"]).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps message_id_full only when it differs from message_id", () => {
|
||||
const prompt = buildInboundMetaSystemPrompt({
|
||||
MessageSid: "short-id",
|
||||
|
||||
@@ -24,6 +24,7 @@ export function buildInboundMetaSystemPrompt(ctx: TemplateContext): string {
|
||||
schema: "openclaw.inbound_meta.v1",
|
||||
message_id: messageId,
|
||||
message_id_full: messageIdFull && messageIdFull !== messageId ? messageIdFull : undefined,
|
||||
sender_id: safeTrim(ctx.SenderId),
|
||||
chat_id: chatId,
|
||||
reply_to_id: replyToId,
|
||||
channel: safeTrim(ctx.OriginatingChannel) ?? safeTrim(ctx.Surface) ?? safeTrim(ctx.Provider),
|
||||
|
||||
Reference in New Issue
Block a user