Skip to content

Commit 226644a

Browse files
committed
Fix custom emoji reaction type deserialization
1 parent 4d05118 commit 226644a

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/types/chat/full_info/tests.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ fn chat_full_info_channel() {
8989
);
9090

9191
let mut expected_struct = expected_struct;
92-
expected_struct.available_reactions = Some(vec![ReactionType::emoji("👍")]);
92+
expected_struct.available_reactions = Some(vec![
93+
ReactionType::emoji("👍"),
94+
ReactionType::Paid,
95+
ReactionType::custom_emoji("5420319826440644296"),
96+
]);
9397
expected_struct.background_custom_emoji_id = Some(String::from("emoji-id"));
9498
expected_struct.has_protected_content = Some(true);
9599
expected_struct.message_auto_delete_time = Some(86400);
@@ -160,7 +164,9 @@ fn chat_full_info_channel() {
160164
{
161165
"type": "emoji",
162166
"emoji": "👍"
163-
}
167+
},
168+
{"type": "paid"},
169+
{"type": "custom_emoji", "custom_emoji_id": "5420319826440644296"},
164170
],
165171
"emoji_status_custom_emoji_id": "emoji-id",
166172
"emoji_status_expiration_date": 0,

src/types/reaction/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ impl ReactionType {
110110
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
111111
#[serde(rename_all = "snake_case", tag = "type")]
112112
enum RawReactionType {
113-
CustomEmoji { custom_emoji: String },
113+
CustomEmoji { custom_emoji_id: String },
114114
Emoji { emoji: String },
115115
Paid,
116116
}
117117

118118
impl From<ReactionType> for RawReactionType {
119119
fn from(value: ReactionType) -> Self {
120120
match value {
121-
ReactionType::CustomEmoji(custom_emoji) => Self::CustomEmoji { custom_emoji },
121+
ReactionType::CustomEmoji(custom_emoji_id) => Self::CustomEmoji { custom_emoji_id },
122122
ReactionType::Emoji(emoji) => Self::Emoji { emoji },
123123
ReactionType::Paid => Self::Paid,
124124
}
@@ -128,7 +128,7 @@ impl From<ReactionType> for RawReactionType {
128128
impl From<RawReactionType> for ReactionType {
129129
fn from(value: RawReactionType) -> Self {
130130
match value {
131-
RawReactionType::CustomEmoji { custom_emoji } => Self::CustomEmoji(custom_emoji),
131+
RawReactionType::CustomEmoji { custom_emoji_id } => Self::CustomEmoji(custom_emoji_id),
132132
RawReactionType::Emoji { emoji } => Self::Emoji(emoji),
133133
RawReactionType::Paid => Self::Paid,
134134
}

src/types/reaction/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ fn reaction_count() {
3030
#[test]
3131
fn reaction_type() {
3232
assert_json_eq(
33-
ReactionType::custom_emoji("🤡"),
33+
ReactionType::custom_emoji("5420319826440644296"),
3434
serde_json::json!({
3535
"type": "custom_emoji",
36-
"custom_emoji": "🤡"
36+
"custom_emoji_id": "5420319826440644296"
3737
}),
3838
);
3939
assert_json_eq(

0 commit comments

Comments
 (0)