diff --git a/xmtp_content_types/src/attachment.rs b/xmtp_content_types/src/attachment.rs new file mode 100644 index 000000000..fcd908944 --- /dev/null +++ b/xmtp_content_types/src/attachment.rs @@ -0,0 +1,6 @@ +pub struct AttachmentCodec {} + +//. Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-remote-attachment/src/Attachment.ts +impl AttachmentCodec { + pub const TYPE_ID: &'static str = "attachment"; +} diff --git a/xmtp_content_types/src/lib.rs b/xmtp_content_types/src/lib.rs index 727a5374f..e6e8d4397 100644 --- a/xmtp_content_types/src/lib.rs +++ b/xmtp_content_types/src/lib.rs @@ -1,3 +1,4 @@ +pub mod attachment; pub mod group_updated; pub mod membership_change; pub mod reaction; diff --git a/xmtp_content_types/src/reaction.rs b/xmtp_content_types/src/reaction.rs index be03f5465..771f03119 100644 --- a/xmtp_content_types/src/reaction.rs +++ b/xmtp_content_types/src/reaction.rs @@ -1,5 +1,6 @@ pub struct ReactionCodec {} +/// Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-reaction/src/Reaction.ts impl ReactionCodec { pub const TYPE_ID: &'static str = "reaction"; } diff --git a/xmtp_content_types/src/read_receipt.rs b/xmtp_content_types/src/read_receipt.rs index bd72e02cf..7c0f34e06 100644 --- a/xmtp_content_types/src/read_receipt.rs +++ b/xmtp_content_types/src/read_receipt.rs @@ -1,5 +1,6 @@ pub struct ReadReceiptCodec {} +/// Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-read-receipt/src/ReadReceipt.ts impl ReadReceiptCodec { - pub const TYPE_ID: &'static str = "read_receipt"; + pub const TYPE_ID: &'static str = "readReceipt"; } diff --git a/xmtp_content_types/src/remote_attachment.rs b/xmtp_content_types/src/remote_attachment.rs index 6cd7ac38d..7d190d32b 100644 --- a/xmtp_content_types/src/remote_attachment.rs +++ b/xmtp_content_types/src/remote_attachment.rs @@ -1,5 +1,6 @@ pub struct RemoteAttachmentCodec {} +//. Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-remote-attachment/src/RemoteAttachment.ts impl RemoteAttachmentCodec { - pub const TYPE_ID: &'static str = "remote_attachment"; + pub const TYPE_ID: &'static str = "remoteStaticAttachment"; } diff --git a/xmtp_content_types/src/reply.rs b/xmtp_content_types/src/reply.rs index bdc0c5add..513effe9d 100644 --- a/xmtp_content_types/src/reply.rs +++ b/xmtp_content_types/src/reply.rs @@ -1,5 +1,6 @@ pub struct ReplyCodec {} +/// Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-reply/src/Reply.ts impl ReplyCodec { pub const TYPE_ID: &'static str = "reply"; } diff --git a/xmtp_content_types/src/transaction_reference.rs b/xmtp_content_types/src/transaction_reference.rs index 0f7898dcf..44df54d6c 100644 --- a/xmtp_content_types/src/transaction_reference.rs +++ b/xmtp_content_types/src/transaction_reference.rs @@ -1,5 +1,6 @@ pub struct TransactionReferenceCodec {} +/// Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-transaction-reference/src/TransactionReference.ts impl TransactionReferenceCodec { - pub const TYPE_ID: &'static str = "transaction_reference"; + pub const TYPE_ID: &'static str = "transactionReference"; } diff --git a/xmtp_mls/src/storage/encrypted_store/group_message.rs b/xmtp_mls/src/storage/encrypted_store/group_message.rs index 5c75c3a79..cfc3d599c 100644 --- a/xmtp_mls/src/storage/encrypted_store/group_message.rs +++ b/xmtp_mls/src/storage/encrypted_store/group_message.rs @@ -7,7 +7,10 @@ use diesel::{ sql_types::Integer, }; use serde::{Deserialize, Serialize}; -use xmtp_content_types::{group_updated, membership_change, text}; +use xmtp_content_types::{ + attachment, group_updated, membership_change, reaction, read_receipt, remote_attachment, reply, + text, transaction_reference, +}; use super::{ db_connection::DbConnection, @@ -86,6 +89,7 @@ where } } +//Legacy content types found at https://github.com/xmtp/xmtp-js/tree/main/content-types #[repr(i32)] #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, FromSqlRow, AsExpression)] #[diesel(sql_type = diesel::sql_types::Integer)] @@ -94,6 +98,12 @@ pub enum ContentType { Text = 1, GroupMembershipChange = 2, GroupUpdated = 3, + Reaction = 4, + ReadReceipt = 5, + Reply = 6, + Attachment = 7, + RemoteAttachment = 8, + TransactionReference = 9, } impl std::fmt::Display for ContentType { @@ -103,6 +113,12 @@ impl std::fmt::Display for ContentType { Self::Text => text::TextCodec::TYPE_ID, Self::GroupMembershipChange => membership_change::GroupMembershipChangeCodec::TYPE_ID, Self::GroupUpdated => group_updated::GroupUpdatedCodec::TYPE_ID, + Self::Reaction => reaction::ReactionCodec::TYPE_ID, + Self::ReadReceipt => read_receipt::ReadReceiptCodec::TYPE_ID, + Self::Attachment => attachment::AttachmentCodec::TYPE_ID, + Self::RemoteAttachment => remote_attachment::RemoteAttachmentCodec::TYPE_ID, + Self::Reply => reply::ReplyCodec::TYPE_ID, + Self::TransactionReference => transaction_reference::TransactionReferenceCodec::TYPE_ID, }; write!(f, "{}", as_string) @@ -115,6 +131,12 @@ impl From for ContentType { text::TextCodec::TYPE_ID => Self::Text, membership_change::GroupMembershipChangeCodec::TYPE_ID => Self::GroupMembershipChange, group_updated::GroupUpdatedCodec::TYPE_ID => Self::GroupUpdated, + reaction::ReactionCodec::TYPE_ID => Self::Reaction, + read_receipt::ReadReceiptCodec::TYPE_ID => Self::ReadReceipt, + reply::ReplyCodec::TYPE_ID => Self::Reply, + attachment::AttachmentCodec::TYPE_ID => Self::Attachment, + remote_attachment::RemoteAttachmentCodec::TYPE_ID => Self::RemoteAttachment, + transaction_reference::TransactionReferenceCodec::TYPE_ID => Self::TransactionReference, _ => Self::Unknown, } } @@ -140,6 +162,12 @@ where 1 => Ok(ContentType::Text), 2 => Ok(ContentType::GroupMembershipChange), 3 => Ok(ContentType::GroupUpdated), + 4 => Ok(ContentType::Reaction), + 5 => Ok(ContentType::ReadReceipt), + 6 => Ok(ContentType::Reply), + 7 => Ok(ContentType::Attachment), + 8 => Ok(ContentType::RemoteAttachment), + 9 => Ok(ContentType::TransactionReference), x => Err(format!("Unrecognized variant {}", x).into()), } }