@automagik/omni 2.260910.12 → 2.260910.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/events.d.ts +22 -0
- package/dist/commands/events.d.ts.map +1 -1
- package/dist/index.js +44 -8
- package/dist/server/index.js +56 -3
- package/package.json +1 -1
|
@@ -137,11 +137,28 @@ export interface FormatLineOptions {
|
|
|
137
137
|
/** Print raw uuid8 ids even when a name is known (#1036 ask 2, `--ids`). */
|
|
138
138
|
ids?: boolean;
|
|
139
139
|
names?: StreamNames;
|
|
140
|
+
/** `--pretty` (#1079): compact colored `time type who: text` line. */
|
|
141
|
+
pretty?: boolean;
|
|
142
|
+
/** Force ANSI on/off (tests); defaults to `areColorsEnabled()`. */
|
|
143
|
+
color?: boolean;
|
|
140
144
|
}
|
|
141
145
|
/** Sender label: resolved person name, then channel push name, then raw `from`. */
|
|
142
146
|
export declare function senderLabel(event: StreamEventRow, names?: StreamNames): string;
|
|
143
147
|
/** Format an event as a single human-readable line. */
|
|
144
148
|
export declare function formatEventLine(event: StreamEventRow, options?: FormatLineOptions): string;
|
|
149
|
+
/**
|
|
150
|
+
* `--pretty` content column (#1079): message text first, then the webhook
|
|
151
|
+
* body fields humans grep for (github: action #number title; purchase: subject).
|
|
152
|
+
* ponytail: one generic key list instead of per-family formatters; add a
|
|
153
|
+
* per-family switch when a family needs a shape this cannot express.
|
|
154
|
+
*/
|
|
155
|
+
export declare function prettyContent(event: StreamEventRow): string;
|
|
156
|
+
/**
|
|
157
|
+
* `--pretty` (#1079): one compact `time type who: text` line, colored when
|
|
158
|
+
* stdout is a TTY and NO_COLOR / --no-color are unset. Sender resolution is
|
|
159
|
+
* the `--verbose` one (`senderLabel`), not a second copy.
|
|
160
|
+
*/
|
|
161
|
+
export declare function formatPrettyLine(event: StreamEventRow, options?: FormatLineOptions): string;
|
|
145
162
|
/**
|
|
146
163
|
* The journal row as the API actually returns it: the generated SDK `Event`
|
|
147
164
|
* type is a projection, but GET /events returns full omni_events rows —
|
|
@@ -213,6 +230,11 @@ export interface FollowParams {
|
|
|
213
230
|
isStopped?: () => boolean;
|
|
214
231
|
/** Line sink — defaults to output.raw (stdout). Injected by tests. */
|
|
215
232
|
emit?: (line: string) => void;
|
|
233
|
+
/** `--pretty` (#1079): print formatPrettyLine instead of JSON lines; names resolved via `client`. */
|
|
234
|
+
pretty?: {
|
|
235
|
+
client: OmniClient;
|
|
236
|
+
format: FormatLineOptions;
|
|
237
|
+
};
|
|
216
238
|
/** Consecutive transport failures tolerated before giving up (default 5). */
|
|
217
239
|
maxRetries?: number;
|
|
218
240
|
/** First backoff delay; doubles per retry up to 30s (default 1000). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/commands/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,KAAK,mBAAmB,EAAsB,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/commands/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,KAAK,mBAAmB,EAAsB,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwJpC,iFAAiF;AACjF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzF;AAqDD,2DAA2D;AAC3D,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE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G,OAAO,CAAC,CAAC,CAAC,CAepH;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAY/E;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,sFAAsF;IACtF,GAAG,EAAE,OAAO,CAAC;IACb,8EAA8E;IAC9E,SAAS,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC;IAC1B,sEAAsE;IACtE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,qGAAqG;IACrG,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,iBAAiB,CAAA;KAAE,CAAC;IAC3D,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA2CD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCxE;AA8FD,wBAAgB,mBAAmB,IAAI,OAAO,CAga7C"}
|
package/dist/index.js
CHANGED
|
@@ -137198,7 +137198,7 @@ import { fileURLToPath } from "url";
|
|
|
137198
137198
|
// package.json
|
|
137199
137199
|
var package_default = {
|
|
137200
137200
|
name: "@automagik/omni",
|
|
137201
|
-
version: "2.260910.
|
|
137201
|
+
version: "2.260910.14",
|
|
137202
137202
|
repository: {
|
|
137203
137203
|
type: "git",
|
|
137204
137204
|
url: "git+https://github.com/automagik-dev/omni.git",
|
|
@@ -143917,10 +143917,12 @@ function createDoneCommand() {
|
|
|
143917
143917
|
|
|
143918
143918
|
// src/commands/events.ts
|
|
143919
143919
|
init_src();
|
|
143920
|
+
init_source();
|
|
143920
143921
|
import { readFileSync as readFileSync11 } from "fs";
|
|
143921
143922
|
init_zod();
|
|
143922
143923
|
init_config();
|
|
143923
143924
|
init_output();
|
|
143925
|
+
init_output();
|
|
143924
143926
|
function parseSinceTime(since) {
|
|
143925
143927
|
const match = since.match(/^(\d+)([hdwm]|min)$/);
|
|
143926
143928
|
if (!match) {
|
|
@@ -144270,6 +144272,29 @@ function formatEventLine(event, options = {}) {
|
|
|
144270
144272
|
}
|
|
144271
144273
|
return `${cols.join(" ")} ${trimmed}`.trimEnd();
|
|
144272
144274
|
}
|
|
144275
|
+
function prettyContent(event) {
|
|
144276
|
+
const text = event.textContent ?? event.transcription ?? event.imageDescription;
|
|
144277
|
+
if (text)
|
|
144278
|
+
return text;
|
|
144279
|
+
const p11 = event.rawPayload ?? {};
|
|
144280
|
+
const nested = p11.pull_request ?? p11.issue ?? {};
|
|
144281
|
+
const str = (v4) => typeof v4 === "string" && v4 ? v4 : undefined;
|
|
144282
|
+
const number2 = p11.number ?? nested.number;
|
|
144283
|
+
const title = ["title", "subject", "text", "message", "body"].map((k4) => str(p11[k4]) ?? str(nested[k4])).find(Boolean);
|
|
144284
|
+
return [str(p11.action), number2 === undefined ? undefined : `#${String(number2)}`, title].filter(Boolean).join(" ");
|
|
144285
|
+
}
|
|
144286
|
+
var chalk2 = new Chalk({ level: 1 });
|
|
144287
|
+
var paint = (on, fn, s2) => on && s2 ? fn(s2) : s2;
|
|
144288
|
+
function formatPrettyLine(event, options = {}) {
|
|
144289
|
+
const color = options.color ?? (areColorsEnabled() && !process.env.NO_COLOR);
|
|
144290
|
+
const time = new Date(event.receivedAt).toISOString().slice(11, 19);
|
|
144291
|
+
const typeColor = isErrorEvent(event.eventType) ? chalk2.red : event.direction === "outbound" ? chalk2.magenta : chalk2.cyan;
|
|
144292
|
+
const who = event.direction === "outbound" && !event.rawPayload?.pushName ? "me" : senderLabel(event, options.names);
|
|
144293
|
+
const content = prettyContent(event);
|
|
144294
|
+
const head = `${paint(color, chalk2.dim, time)} ${paint(color, typeColor, event.eventType)}`;
|
|
144295
|
+
const tail = [paint(color, chalk2.bold, who), content].filter(Boolean).join(": ");
|
|
144296
|
+
return `${head} ${tail}`.trimEnd();
|
|
144297
|
+
}
|
|
144273
144298
|
async function warmStreamNames(client, names, events2) {
|
|
144274
144299
|
const lookup2 = async (map2, id, fetch2) => {
|
|
144275
144300
|
if (map2.has(id))
|
|
@@ -144294,7 +144319,7 @@ function emitStreamEvent(event, ndjson, format) {
|
|
|
144294
144319
|
if (ndjson) {
|
|
144295
144320
|
raw(JSON.stringify(event));
|
|
144296
144321
|
} else {
|
|
144297
|
-
raw(formatEventLine(event, format));
|
|
144322
|
+
raw(format.pretty ? formatPrettyLine(event, format) : formatEventLine(event, format));
|
|
144298
144323
|
}
|
|
144299
144324
|
}
|
|
144300
144325
|
async function fetchStreamBatch(client, filters, channel2, type, sinceIso) {
|
|
@@ -144356,6 +144381,7 @@ async function streamEvents(client, options) {
|
|
|
144356
144381
|
const format = {
|
|
144357
144382
|
verbose: options.verbose,
|
|
144358
144383
|
ids: options.ids,
|
|
144384
|
+
pretty: options.pretty,
|
|
144359
144385
|
names: { instances: new Map, chats: new Map, persons: new Map }
|
|
144360
144386
|
};
|
|
144361
144387
|
let stopped = false;
|
|
@@ -144472,6 +144498,14 @@ async function pullWithRetry(params) {
|
|
|
144472
144498
|
}
|
|
144473
144499
|
}
|
|
144474
144500
|
}
|
|
144501
|
+
async function emitFollowPage(params, items, emit) {
|
|
144502
|
+
const pretty = params.pretty;
|
|
144503
|
+
if (pretty?.format.names && !pretty.format.ids)
|
|
144504
|
+
await warmStreamNames(pretty.client, pretty.format.names, items);
|
|
144505
|
+
for (const item of items) {
|
|
144506
|
+
emit(pretty ? formatPrettyLine(item, pretty.format) : JSON.stringify(item));
|
|
144507
|
+
}
|
|
144508
|
+
}
|
|
144475
144509
|
async function followConsumer(params) {
|
|
144476
144510
|
const emit = params.emit ?? raw;
|
|
144477
144511
|
let acked = -1;
|
|
@@ -144479,9 +144513,7 @@ async function followConsumer(params) {
|
|
|
144479
144513
|
if (params.isStopped?.())
|
|
144480
144514
|
return;
|
|
144481
144515
|
const page = await pullWithRetry(params);
|
|
144482
|
-
|
|
144483
|
-
emit(JSON.stringify(item));
|
|
144484
|
-
}
|
|
144516
|
+
await emitFollowPage(params, page.items, emit);
|
|
144485
144517
|
if (!params.ack) {
|
|
144486
144518
|
await flushStdout();
|
|
144487
144519
|
return;
|
|
@@ -144583,7 +144615,7 @@ function createEventsCommand() {
|
|
|
144583
144615
|
error(`Failed to list events: ${message2}`);
|
|
144584
144616
|
}
|
|
144585
144617
|
});
|
|
144586
|
-
events2.command("stream").description("Stream events in real-time (tail -f style). Ctrl+C to stop.").option("--instance <id>", "Filter by instance ID").option("--channel <type>", "Filter by channel type").option("--type <type>", "Filter by event type (trailing * = prefix glob, e.g. custom.*)").option("--exclude <glob>", "Drop event types matching this glob, repeatable; wins over --type (e.g. --exclude custom.chat.*)", (value, previous) => [...previous, value], []).option("--chat-id <id>", "Filter by chat ID").option("--person-id <id>", "Filter by person ID").option("--since <time>", "Start cursor (e.g., 5min, 24h, 7d, or ISO timestamp)").option("--errors-only", "Show only error/failure events").option("--all", "Include noisy event types (presence, delivered, read, progress)").option("--ndjson", "Emit JSON Lines (one event per line) \u2014 same as global --json in stream mode").option("-v, --verbose", "Add sender, fromMe marker and contentType columns").option("--ids", "Print raw ids instead of resolved instance/chat names").option("--poll-ms <n>", "Polling interval in milliseconds", (v4) => Number.parseInt(v4, 10), 2000).action(async (options) => {
|
|
144618
|
+
events2.command("stream").description("Stream events in real-time (tail -f style). Ctrl+C to stop.").option("--instance <id>", "Filter by instance ID").option("--channel <type>", "Filter by channel type").option("--type <type>", "Filter by event type (trailing * = prefix glob, e.g. custom.*)").option("--exclude <glob>", "Drop event types matching this glob, repeatable; wins over --type (e.g. --exclude custom.chat.*)", (value, previous) => [...previous, value], []).option("--chat-id <id>", "Filter by chat ID").option("--person-id <id>", "Filter by person ID").option("--since <time>", "Start cursor (e.g., 5min, 24h, 7d, or ISO timestamp)").option("--errors-only", "Show only error/failure events").option("--all", "Include noisy event types (presence, delivered, read, progress)").option("--ndjson", "Emit JSON Lines (one event per line) \u2014 same as global --json in stream mode").option("-v, --verbose", "Add sender, fromMe marker and contentType columns").option("--ids", "Print raw ids instead of resolved instance/chat names").option("--pretty", "One colored `time type who: text` line per event (no ANSI when piped or NO_COLOR)").option("--poll-ms <n>", "Polling interval in milliseconds", (v4) => Number.parseInt(v4, 10), 2000).action(async (options) => {
|
|
144587
144619
|
const client = getClient();
|
|
144588
144620
|
try {
|
|
144589
144621
|
await streamEvents(client, options);
|
|
@@ -144628,7 +144660,7 @@ function createEventsCommand() {
|
|
|
144628
144660
|
error(`Failed to wait for event: ${message2}`);
|
|
144629
144661
|
}
|
|
144630
144662
|
});
|
|
144631
|
-
events2.command("follow").description("Tail the journal through a durable consumer: resumes from its stored cursor, prints JSON lines, acks as it goes.").requiredOption("--consumer <name>", "Durable consumer to follow (create with: omni events consumers create)").option("--limit <n>", "Max journal rows scanned per pull", (v4) => Number.parseInt(v4, 10), 100).option("--wait-ms <n>", "Server-side long-poll window per pull when idle (max 30000)", (v4) => Number.parseInt(v4, 10), 1e4).option("--no-ack", "Peek: print one page without advancing the cursor, then exit").option("--until-idle", "Exit 0 once caught up with the journal instead of tailing forever").option("--ndjson", "Accepted for symmetry with `events stream` \u2014 follow
|
|
144663
|
+
events2.command("follow").description("Tail the journal through a durable consumer: resumes from its stored cursor, prints JSON lines, acks as it goes.").requiredOption("--consumer <name>", "Durable consumer to follow (create with: omni events consumers create)").option("--limit <n>", "Max journal rows scanned per pull", (v4) => Number.parseInt(v4, 10), 100).option("--wait-ms <n>", "Server-side long-poll window per pull when idle (max 30000)", (v4) => Number.parseInt(v4, 10), 1e4).option("--no-ack", "Peek: print one page without advancing the cursor, then exit").option("--until-idle", "Exit 0 once caught up with the journal instead of tailing forever").option("--ndjson", "Accepted for symmetry with `events stream` \u2014 follow emits JSON Lines unless --pretty").option("--pretty", "One colored `time type who: text` line per event (no ANSI when piped or NO_COLOR)").option("--ids", "With --pretty: print raw ids instead of resolved names").action(async (options) => {
|
|
144632
144664
|
let stopped = false;
|
|
144633
144665
|
const shutdown = () => {
|
|
144634
144666
|
stopped = true;
|
|
@@ -144643,7 +144675,11 @@ function createEventsCommand() {
|
|
|
144643
144675
|
waitMs: Math.min(Math.max(options.waitMs, 0), 30000),
|
|
144644
144676
|
ack: options.ack,
|
|
144645
144677
|
untilIdle: options.untilIdle === true,
|
|
144646
|
-
isStopped: () => stopped
|
|
144678
|
+
isStopped: () => stopped,
|
|
144679
|
+
pretty: options.pretty && !options.ndjson && getOutputFormat() !== "json" ? {
|
|
144680
|
+
client: getClient(),
|
|
144681
|
+
format: { ids: options.ids, names: { instances: new Map, chats: new Map, persons: new Map } }
|
|
144682
|
+
} : undefined
|
|
144647
144683
|
});
|
|
144648
144684
|
} catch (err2) {
|
|
144649
144685
|
error(`Failed to follow consumer: ${errorMessage(err2)}`);
|
package/dist/server/index.js
CHANGED
|
@@ -251645,7 +251645,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
251645
251645
|
var require_package7 = __commonJS((exports, module) => {
|
|
251646
251646
|
module.exports = {
|
|
251647
251647
|
name: "@omni/api",
|
|
251648
|
-
version: "2.260910.
|
|
251648
|
+
version: "2.260910.14",
|
|
251649
251649
|
private: true,
|
|
251650
251650
|
type: "module",
|
|
251651
251651
|
exports: {
|
|
@@ -363797,6 +363797,19 @@ async function postProcessChat(services, chat2, _chatCreated, chatExternalId, ch
|
|
|
363797
363797
|
function resolveSenderDisplayName(senderName, rawPayload, participantResult) {
|
|
363798
363798
|
return truncate4(senderName ?? rawPayload?.pushName, 255) || participantResult?.participant.displayName || undefined;
|
|
363799
363799
|
}
|
|
363800
|
+
async function resolveQuotedSenderName(services, chatId, quotedMessage) {
|
|
363801
|
+
const pushName = truncate4(quotedMessage?.pushName, 255);
|
|
363802
|
+
if (pushName)
|
|
363803
|
+
return pushName;
|
|
363804
|
+
const participant = quotedMessage?.participant;
|
|
363805
|
+
if (!participant)
|
|
363806
|
+
return;
|
|
363807
|
+
const platformUserId = participant.split("@")[0]?.split(":")[0];
|
|
363808
|
+
if (!platformUserId)
|
|
363809
|
+
return;
|
|
363810
|
+
const existing = await services.chats.findParticipant(chatId, platformUserId);
|
|
363811
|
+
return truncate4(existing?.displayName ?? undefined, 255);
|
|
363812
|
+
}
|
|
363800
363813
|
async function maybeFindOrCreateParticipant(services, chatId, from, rawPayload, personId, platformIdentityId, senderName) {
|
|
363801
363814
|
if (!from)
|
|
363802
363815
|
return;
|
|
@@ -363956,7 +363969,7 @@ async function handleMessageReceived(services, payload, metadata, eventTimestamp
|
|
|
363956
363969
|
mediaLocalPath: rawPayload?.mediaLocalPath,
|
|
363957
363970
|
replyToExternalId: truncate4(payload.replyToId, 255),
|
|
363958
363971
|
quotedText: quotedMessage?.conversation,
|
|
363959
|
-
quotedSenderName:
|
|
363972
|
+
quotedSenderName: await resolveQuotedSenderName(services, chat2.id, quotedMessage),
|
|
363960
363973
|
threadExternalId: truncate4(payload.threadId, 255),
|
|
363961
363974
|
isThreadBroadcast: rawPayload?.isThreadBroadcast === true,
|
|
363962
363975
|
isForwarded: !!(rawPayload?.isForwarded || rawPayload?.forwardingScore),
|
|
@@ -370062,8 +370075,12 @@ class ChatService {
|
|
|
370062
370075
|
}).where(eq(chatParticipants.id, existing.id)).returning();
|
|
370063
370076
|
return updated ?? existing;
|
|
370064
370077
|
}
|
|
370065
|
-
async
|
|
370078
|
+
async findParticipant(chatId, platformUserId) {
|
|
370066
370079
|
const [existing] = await this.db.select().from(chatParticipants).where(and2(eq(chatParticipants.chatId, chatId), eq(chatParticipants.platformUserId, platformUserId))).limit(1);
|
|
370080
|
+
return existing;
|
|
370081
|
+
}
|
|
370082
|
+
async findOrCreateParticipant(chatId, platformUserId, defaults2 = {}) {
|
|
370083
|
+
const existing = await this.findParticipant(chatId, platformUserId);
|
|
370067
370084
|
if (existing) {
|
|
370068
370085
|
const hasNewIdentity = defaults2.personId || defaults2.platformIdentityId;
|
|
370069
370086
|
const missingIdentity = !existing.personId || !existing.platformIdentityId;
|
|
@@ -398043,6 +398060,16 @@ async function resolveChatLink(db2, instanceId, chatId) {
|
|
|
398043
398060
|
return NO_CHAT_LINK;
|
|
398044
398061
|
}
|
|
398045
398062
|
}
|
|
398063
|
+
async function resolveReplyToEventId(db2, instanceId, replyToExternalId) {
|
|
398064
|
+
if (!instanceId || !replyToExternalId)
|
|
398065
|
+
return null;
|
|
398066
|
+
try {
|
|
398067
|
+
const [row] = await db2.select({ id: omniEvents.id }).from(omniEvents).where(and2(eq(omniEvents.instanceId, instanceId), eq(omniEvents.externalId, replyToExternalId))).orderBy(omniEvents.receivedAt).limit(1);
|
|
398068
|
+
return row?.id ?? null;
|
|
398069
|
+
} catch {
|
|
398070
|
+
return null;
|
|
398071
|
+
}
|
|
398072
|
+
}
|
|
398046
398073
|
async function resolvePersonId2(db2, candidate) {
|
|
398047
398074
|
if (typeof candidate !== "string" || !isValidUuid(candidate))
|
|
398048
398075
|
return null;
|
|
@@ -398077,6 +398104,7 @@ async function setupEventPersistence(eventBus, db2) {
|
|
|
398077
398104
|
await runConsumerInTenantContext(db2, event, async () => {
|
|
398078
398105
|
const sdb = scopedHandle(db2);
|
|
398079
398106
|
const chatLink = await resolveChatLink(sdb, metadata.instanceId, payload.chatId);
|
|
398107
|
+
const replyToEventId = await resolveReplyToEventId(sdb, metadata.instanceId, payload.replyToId);
|
|
398080
398108
|
const columns2 = {
|
|
398081
398109
|
externalId: payload.externalId,
|
|
398082
398110
|
channel: mapChannelType(metadata.channelType),
|
|
@@ -398091,6 +398119,7 @@ async function setupEventPersistence(eventBus, db2) {
|
|
|
398091
398119
|
mediaMimeType: payload.content.mimeType,
|
|
398092
398120
|
chatId: payload.chatId,
|
|
398093
398121
|
replyToExternalId: payload.replyToId,
|
|
398122
|
+
replyToEventId,
|
|
398094
398123
|
status: "received",
|
|
398095
398124
|
receivedAt: new Date(event.timestamp),
|
|
398096
398125
|
rawPayload: payload.rawPayload ? deepSanitize(payload.rawPayload) : undefined,
|
|
@@ -398127,6 +398156,7 @@ async function setupEventPersistence(eventBus, db2) {
|
|
|
398127
398156
|
await runConsumerInTenantContext(db2, event, async () => {
|
|
398128
398157
|
const sdb = scopedHandle(db2);
|
|
398129
398158
|
const chatLink = await resolveChatLink(sdb, metadata.instanceId, payload.chatId);
|
|
398159
|
+
const replyToEventId = await resolveReplyToEventId(sdb, metadata.instanceId, payload.replyToId);
|
|
398130
398160
|
const newEvent = {
|
|
398131
398161
|
...eventIdInsert(event.id),
|
|
398132
398162
|
externalId: payload.externalId,
|
|
@@ -398142,6 +398172,7 @@ async function setupEventPersistence(eventBus, db2) {
|
|
|
398142
398172
|
mediaMimeType: payload.content.mimeType,
|
|
398143
398173
|
chatId: payload.chatId,
|
|
398144
398174
|
replyToExternalId: payload.replyToId,
|
|
398175
|
+
replyToEventId,
|
|
398145
398176
|
status: "completed",
|
|
398146
398177
|
receivedAt: new Date(event.timestamp),
|
|
398147
398178
|
processedAt: new Date,
|
|
@@ -528591,6 +528622,19 @@ function getReplyToId2(msg) {
|
|
|
528591
528622
|
const contextInfo = getMessageContextInfo(msg);
|
|
528592
528623
|
return contextInfo?.stanzaId || undefined;
|
|
528593
528624
|
}
|
|
528625
|
+
function extractQuotedContext(msg) {
|
|
528626
|
+
const contextInfo = getMessageContextInfo(msg);
|
|
528627
|
+
if (!contextInfo?.quotedMessage)
|
|
528628
|
+
return;
|
|
528629
|
+
const content = extractContent3({ key: msg.key, message: contextInfo.quotedMessage });
|
|
528630
|
+
const type = content?.type ?? "unknown";
|
|
528631
|
+
return {
|
|
528632
|
+
stanzaId: contextInfo.stanzaId || undefined,
|
|
528633
|
+
participant: contextInfo.participant || undefined,
|
|
528634
|
+
type,
|
|
528635
|
+
conversation: content?.text || content?.caption || `[${type}]`
|
|
528636
|
+
};
|
|
528637
|
+
}
|
|
528594
528638
|
function isFromMe(msg) {
|
|
528595
528639
|
return msg.key.fromMe === true;
|
|
528596
528640
|
}
|
|
@@ -531691,6 +531735,7 @@ class WhatsAppPlugin extends BaseChannelPlugin {
|
|
|
531691
531735
|
}
|
|
531692
531736
|
} catch {}
|
|
531693
531737
|
}
|
|
531738
|
+
await this.enrichPayloadWithQuotedMessage(extendedPayload, instanceId, chatId, rawMessage);
|
|
531694
531739
|
if (content.poll)
|
|
531695
531740
|
extendedPayload.poll = content.poll;
|
|
531696
531741
|
if (content.pollVotes)
|
|
@@ -532223,6 +532268,7 @@ class WhatsAppPlugin extends BaseChannelPlugin {
|
|
|
532223
532268
|
if (content.localPath)
|
|
532224
532269
|
rawPayload.mediaLocalPath = content.localPath;
|
|
532225
532270
|
this.enrichPayloadWithChatName(rawPayload, instanceId, chatId);
|
|
532271
|
+
await this.enrichPayloadWithQuotedMessage(rawPayload, instanceId, chatId, msg);
|
|
532226
532272
|
const historySenderName = msg.pushName ?? undefined;
|
|
532227
532273
|
await this.emitMessageReceived({
|
|
532228
532274
|
instanceId,
|
|
@@ -532242,6 +532288,13 @@ class WhatsAppPlugin extends BaseChannelPlugin {
|
|
|
532242
532288
|
});
|
|
532243
532289
|
}
|
|
532244
532290
|
}
|
|
532291
|
+
async enrichPayloadWithQuotedMessage(rawPayload, instanceId, chatId, msg) {
|
|
532292
|
+
const quoted = extractQuotedContext(msg);
|
|
532293
|
+
if (!quoted)
|
|
532294
|
+
return;
|
|
532295
|
+
const pushName = quoted.participant ? (await this.getContactInfo(instanceId, quoted.participant, chatId))?.name : undefined;
|
|
532296
|
+
rawPayload.quotedMessage = { ...quoted, pushName };
|
|
532297
|
+
}
|
|
532245
532298
|
enrichPayloadWithChatName(payload, instanceId, chatId) {
|
|
532246
532299
|
if (chatId.includes("@g.us")) {
|
|
532247
532300
|
const group = this.groupsCache.get(instanceId)?.get(chatId);
|