Replies: 2 comments 6 replies
-
Hi @MallRoy, We currently don't support read-receipts natively but can be done through customized contentTypes. To learn more about content types, see Different types of content. To learn how to use content types when developing a client app, see Use content types. Feel free to let me know if you have additional questions! Thanks! |
Beta Was this translation helpful? Give feedback.
4 replies
-
So, based on the current thread, there is a possibility that we will implement this. Codec example with content types; import {ContentTypeId, EncodedContent} from "@xmtp/xmtp-js";
import {ContentCodec} from "@xmtp/xmtp-js";
export interface ReadReceiptContent {
conversationId?: string
messageId: string
}
export const ContentTypeReadReceipt = new ContentTypeId({
authorityId: 'xmtp.org',
typeId: 'read-receipt',
versionMajor: 1,
versionMinor: 0,
});
export function isReadReceipt(arg: any): arg is ReadReceiptContent {
return arg &&
arg.messageId &&
typeof arg.messageId === "string" &&
((arg.conversationId &&
typeof arg.conversationId === "string") || arg.conversationId === undefined || arg.conversationId === null)
}
export const ReadReceiptCodec = (): ContentCodec<ReadReceiptContent> => {
return {
contentType: ContentTypeReadReceipt,
encode: (content: ReadReceiptContent): EncodedContent => {
if(!isReadReceipt(content)) {
throw new Error(`Type error, the content we get is not a valid ReadReceiptContent!`);
}
return {
type: ContentTypeReadReceipt,
parameters: {},
fallback: `I read ${content.messageId} in the ${content.conversationId} conversation`,
content: new TextEncoder().encode(JSON.stringify(content)),
};
},
decode: (content: EncodedContent): ReadReceiptContent => {
const encoding = content.parameters.encoding;
if (encoding && encoding !== "UTF-8") {
throw new Error(`unrecognized encoding ${encoding}`);
}
const contentString = new TextDecoder().decode(content.content);
const obj = JSON.parse(contentString)
if(isReadReceipt(content)) {
return obj
} else {
throw new Error(`Content is malformed! ${JSON.stringify(obj)}`);
}
}
}
} We would send it to a custom conversation topic/id I would be happy to get name ideas for that. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
is there a way to identify whether the conversation is read or not
Beta Was this translation helpful? Give feedback.
All reactions