diff --git a/.changeset/sour-jobs-share.md b/.changeset/sour-jobs-share.md new file mode 100644 index 000000000..7fc1aaa83 --- /dev/null +++ b/.changeset/sour-jobs-share.md @@ -0,0 +1,5 @@ +--- +"@xmtp/xmtp.chat": patch +--- + +fix: detect remote static attachments in chat diff --git a/apps/xmtp.chat/src/helpers/messages.test.ts b/apps/xmtp.chat/src/helpers/messages.test.ts index 1494e8763..bd82a350b 100644 --- a/apps/xmtp.chat/src/helpers/messages.test.ts +++ b/apps/xmtp.chat/src/helpers/messages.test.ts @@ -1,5 +1,6 @@ import { contentTypeReaction, + contentTypeRemoteAttachment, contentTypeReply, contentTypeText, DeliveryStatus, @@ -9,10 +10,11 @@ import { type DecodedMessage, type EnrichedReply, type Reaction, + type RemoteAttachment, } from "@xmtp/browser-sdk"; import { type ContentTypeId } from "@xmtp/content-type-primitives"; import { describe, expect, it } from "vitest"; -import { stringify } from "./messages"; +import { isActionable, isRemoteAttachment, stringify } from "./messages"; const createDecodedMessage = ( content: T, @@ -98,3 +100,25 @@ describe("stringify", () => { expect(stringify(decodedMessage)).toBe(fallback); }); }); + +describe("isRemoteAttachment", () => { + it("recognizes remote static attachment messages", async () => { + const content: RemoteAttachment = { + contentDigest: "digest", + contentLength: 42, + filename: "image.png", + nonce: new Uint8Array([1]), + salt: new Uint8Array([2]), + secret: new Uint8Array([3]), + scheme: "https://", + url: "https://example.com/image.png", + }; + const decodedMessage = createDecodedMessage( + content, + await contentTypeRemoteAttachment(), + ); + + expect(isRemoteAttachment(decodedMessage)).toBe(true); + expect(isActionable(decodedMessage)).toBe(true); + }); +}); diff --git a/apps/xmtp.chat/src/helpers/messages.ts b/apps/xmtp.chat/src/helpers/messages.ts index 34eb3e38b..0de23c087 100644 --- a/apps/xmtp.chat/src/helpers/messages.ts +++ b/apps/xmtp.chat/src/helpers/messages.ts @@ -24,7 +24,7 @@ export const isText = (m: DecodedMessage): m is DecodedMessage => export const isRemoteAttachment = ( m: DecodedMessage, ): m is DecodedMessage => - m.contentType.typeId === "staticRemoteAttachment"; + m.contentType.typeId === "remoteStaticAttachment"; export const stringify = (message: DecodedMessage): string => { switch (true) {