Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

refactor(dashboard): quote only by WhatsApp id in the composer

Yudhi Armyndharis841eb1e86f12
diff --git a/dashboard/src/utils/composerSend.test.ts b/dashboard/src/utils/composerSend.test.ts
index 0fc55f86b..7e6c03a37 100644
--- a/dashboard/src/utils/composerSend.test.ts
+++ b/dashboard/src/utils/composerSend.test.ts
@@ -22,12 +22,14 @@ const ATTACHMENT = { base64: 'AAAA', mimetype: 'image/png', filename: 'a.png' };
// Stands in for the composer's localized labeler.
const label = (type: string) => `[${type === 'image' ? 'Image' : type}]`;
-test('quotedIdOf prefers the WhatsApp id over the local one', () => {
+test('quotedIdOf quotes by the WhatsApp id', () => {
assert.equal(quotedIdOf(REPLY), '[email protected]_3EB0');
});
-test('quotedIdOf falls back to the local id before the echo assigns a WA id', () => {
- assert.equal(quotedIdOf({ ...REPLY, waMessageId: undefined }), 'local-1');
+// A local temp_/sent_ id is not something the gateway can resolve: sending it as the quote fails the
+// send with a 404 instead of keeping the quote, so a message without a WA id is not quotable.
+test('quotedIdOf never falls back to the local id', () => {
+ assert.equal(quotedIdOf({ ...REPLY, waMessageId: undefined }), undefined);
});
test('quotedIdOf yields nothing when not replying', () => {
diff --git a/dashboard/src/utils/composerSend.ts b/dashboard/src/utils/composerSend.ts
index bc47f0361..3356fffd4 100644
--- a/dashboard/src/utils/composerSend.ts
+++ b/dashboard/src/utils/composerSend.ts
@@ -29,13 +29,11 @@ export interface OptimisticMetadata {
}
/**
- * The id to quote. The WhatsApp id wins, but a message that has only just been sent optimistically
- * has no WA id yet, so the local id is the fallback — replying to your own just-sent message is an
- * ordinary thing to do and must not silently lose its quote.
+ * The id to quote. Only a message that carries a WhatsApp id can be quoted: a local temp_/sent_ id is
+ * one the gateway can never resolve, so the thread hides Reply on a bubble that has no WA id yet.
*/
export function quotedIdOf(replyingTo: QuotableMessage | null | undefined): string | undefined {
- if (!replyingTo) return undefined;
- return replyingTo.waMessageId || replyingTo.id;
+ return replyingTo?.waMessageId || undefined;
}
/**