Skip to content

Commit

Permalink
Merge pull request #147 from xmtp/np/consuming-custom-content-types
Browse files Browse the repository at this point in the history
feat: add fallback types to content types
  • Loading branch information
nplasterer authored Nov 2, 2023
2 parents 31bdfec + c944481 commit cb62530
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DecodedMessageWrapper {
"content" to ContentJson(model.encodedContent).toJsonMap(),
"senderAddress" to model.senderAddress,
"sent" to model.sent.time,
"fallback" to model.fallbackContent
)
}
}
8 changes: 8 additions & 0 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ test("can list batch messages", async () => {
throw Error("Unexpected message content " + messages[0].content);
}

if (messages[0].fallback !== 'Reacted “💖” to an earlier message') {
throw Error("Unexpected message fallback " + messages[0].fallback);
}

return true;
});

Expand Down Expand Up @@ -488,6 +492,10 @@ test("can send read receipts", async () => {
throw Error("Unexpected message content " + bobMessages[0].content);
}

if (bobMessages[0].fallback) {
throw Error("Unexpected message fallback " + bobMessages[0].fallback);
}

return true;
});

Expand Down
1 change: 1 addition & 0 deletions ios/Wrappers/DecodedMessageWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct DecodedMessageWrapper {
"content": ContentJson.fromEncoded(model.encodedContent, client: model.client).toJsonMap() as Any,
"senderAddress": model.senderAddress,
"sent": UInt64(model.sent.timeIntervalSince1970 * 1000),
"fallback": model.fallbackContent
]
}

Expand Down
1 change: 1 addition & 0 deletions src/XMTP.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export type DecodedMessage = {
content: MessageContent;
senderAddress: string;
sent: number; // timestamp in milliseconds
fallback: string | undefined;
};

export type ConversationContext = {
Expand Down

0 comments on commit cb62530

Please sign in to comment.