Skip to content

Commit

Permalink
get content id strings straight from codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Dec 19, 2024
1 parent 832a497 commit 507b885
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion xmtp_content_types/src/group_updated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GroupUpdated> for GroupUpdatedCodec {
Expand Down
12 changes: 6 additions & 6 deletions xmtp_content_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ 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,
}
}

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,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion xmtp_content_types/src/membership_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GroupMembershipChanges> for GroupMembershipChangeCodec {
Expand Down
2 changes: 1 addition & 1 deletion xmtp_content_types/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down

0 comments on commit 507b885

Please sign in to comment.