From 507b885be78d2dd62a9ae7572ea8eacc1a9e7dda Mon Sep 17 00:00:00 2001 From: cameronvoell Date: Thu, 19 Dec 2024 09:45:35 -0800 Subject: [PATCH] get content id strings straight from codecs --- xmtp_content_types/src/group_updated.rs | 2 +- xmtp_content_types/src/lib.rs | 12 ++++++------ xmtp_content_types/src/membership_change.rs | 2 +- xmtp_content_types/src/text.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/xmtp_content_types/src/group_updated.rs b/xmtp_content_types/src/group_updated.rs index 2ab08917a..6ef0e33f8 100644 --- a/xmtp_content_types/src/group_updated.rs +++ b/xmtp_content_types/src/group_updated.rs @@ -10,7 +10,7 @@ pub struct GroupUpdatedCodec {} impl GroupUpdatedCodec { const AUTHORITY_ID: &'static str = "xmtp.org"; - const TYPE_ID: &'static str = "group_updated"; + pub const TYPE_ID: &'static str = "group_updated"; } impl ContentCodec for GroupUpdatedCodec { diff --git a/xmtp_content_types/src/lib.rs b/xmtp_content_types/src/lib.rs index ce89ed9f7..c3453908a 100644 --- a/xmtp_content_types/src/lib.rs +++ b/xmtp_content_types/src/lib.rs @@ -30,9 +30,9 @@ pub enum ContentType { impl ContentType { pub fn from_string(type_id: &str) -> Self { match type_id { - "text" => Self::Text, - "group_membership_change" => Self::GroupMembershipChange, - "group_updated" => Self::GroupUpdated, + text::TextCodec::TYPE_ID => Self::Text, + membership_change::GroupMembershipChangeCodec::TYPE_ID => Self::GroupMembershipChange, + group_updated::GroupUpdatedCodec::TYPE_ID => Self::GroupUpdated, _ => Self::Unknown, } } @@ -40,9 +40,9 @@ impl ContentType { pub fn to_string(&self) -> &'static str { match self { Self::Unknown => "unknown", - Self::Text => "text", - Self::GroupMembershipChange => "group_membership_change", - Self::GroupUpdated => "group_updated", + Self::Text => text::TextCodec::TYPE_ID, + Self::GroupMembershipChange => membership_change::GroupMembershipChangeCodec::TYPE_ID, + Self::GroupUpdated => group_updated::GroupUpdatedCodec::TYPE_ID, } } } diff --git a/xmtp_content_types/src/membership_change.rs b/xmtp_content_types/src/membership_change.rs index 14401bbb8..bfb65fea7 100644 --- a/xmtp_content_types/src/membership_change.rs +++ b/xmtp_content_types/src/membership_change.rs @@ -12,7 +12,7 @@ pub struct GroupMembershipChangeCodec {} impl GroupMembershipChangeCodec { const AUTHORITY_ID: &'static str = "xmtp.org"; - const TYPE_ID: &'static str = "group_membership_change"; + pub const TYPE_ID: &'static str = "group_membership_change"; } impl ContentCodec for GroupMembershipChangeCodec { diff --git a/xmtp_content_types/src/text.rs b/xmtp_content_types/src/text.rs index 124fb7831..64bf0c93a 100644 --- a/xmtp_content_types/src/text.rs +++ b/xmtp_content_types/src/text.rs @@ -8,7 +8,7 @@ pub struct TextCodec {} impl TextCodec { const AUTHORITY_ID: &'static str = "xmtp.org"; - const TYPE_ID: &'static str = "text"; + pub const TYPE_ID: &'static str = "text"; const ENCODING_KEY: &'static str = "encoding"; const ENCODING_UTF8: &'static str = "UTF-8"; }