BlueGit

ict rusty-teams

fix(app): send reactions as emoji, not legacy names

Graph answered 400 "Unicode 'like' in the payload is not supported".
Own reactions are matched by glyph, so a stored "like" and a stored
thumbs-up both count when toggling off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-08 · 7 weeks ago

Hash
2f154c6ebb4e2e1ffbecf5747627939f3adee89d
Parent
595d83e1
2 files changed +25 −4
crates/app/src/rows.rs +18 −0
@@ -267,6 +267,20 @@ pub fn reaction_label(reaction_type: &str) -> String {
267 267 }
268 268 }
269 269
270 pub fn reaction_glyph(reaction_type: &str) -> String {
271 reaction_label(reaction_type)
272 .trim_end_matches('\u{FE0F}')
273 .to_owned()
274 }
275
276 /// Graph rejects the legacy names ("Unicode 'like' in the payload is not supported").
277 pub fn api_reaction(glyph: &str) -> String {
278 match glyph {
279 "\u{2764}" => "\u{2764}\u{FE0F}".to_owned(),
280 other => other.to_owned(),
281 }
282 }
283
270 284 /// The reaction type Teams uses for a glyph: the legacy name for the six classic ones.
271 285 pub fn reaction_type_for(glyph: &str) -> String {
272 286 let bare = glyph.trim_end_matches('\u{FE0F}');
@@ -598,6 +612,10 @@ mod tests {
598 612 assert_eq!(reaction_type_for("\u{1F44D}"), "like");
599 613 assert_eq!(reaction_type_for("\u{2764}\u{FE0F}"), "heart");
600 614 assert_eq!(reaction_type_for("\u{1F389}"), "\u{1F389}");
615 assert_eq!(reaction_glyph("like"), reaction_glyph("\u{1F44D}"));
616 assert_eq!(reaction_glyph("heart"), reaction_glyph("\u{2764}\u{FE0F}"));
617 assert_eq!(api_reaction(&reaction_glyph("heart")), "\u{2764}\u{FE0F}");
618 assert_eq!(api_reaction(&reaction_glyph("like")), "\u{1F44D}");
601 619 }
602 620
603 621 #[test]
@@ -267,6 +267,20 @@ pub fn reaction_label(reaction_type: &str) -> String {
267 }
267 }
268}
268}
269
269
270pub fn reaction_glyph(reaction_type: &str) -> String {
271 reaction_label(reaction_type)
272 .trim_end_matches('\u{FE0F}')
273 .to_owned()
274}
275
276/// Graph rejects the legacy names ("Unicode 'like' in the payload is not supported").
277pub fn api_reaction(glyph: &str) -> String {
278 match glyph {
279 "\u{2764}" => "\u{2764}\u{FE0F}".to_owned(),
280 other => other.to_owned(),
281 }
282}
283
270/// The reaction type Teams uses for a glyph: the legacy name for the six classic ones.
284/// The reaction type Teams uses for a glyph: the legacy name for the six classic ones.
271pub fn reaction_type_for(glyph: &str) -> String {
285pub fn reaction_type_for(glyph: &str) -> String {
272 let bare = glyph.trim_end_matches('\u{FE0F}');
286 let bare = glyph.trim_end_matches('\u{FE0F}');
@@ -598,6 +612,10 @@ mod tests {
598 assert_eq!(reaction_type_for("\u{1F44D}"), "like");
612 assert_eq!(reaction_type_for("\u{1F44D}"), "like");
599 assert_eq!(reaction_type_for("\u{2764}\u{FE0F}"), "heart");
613 assert_eq!(reaction_type_for("\u{2764}\u{FE0F}"), "heart");
600 assert_eq!(reaction_type_for("\u{1F389}"), "\u{1F389}");
614 assert_eq!(reaction_type_for("\u{1F389}"), "\u{1F389}");
615 assert_eq!(reaction_glyph("like"), reaction_glyph("\u{1F44D}"));
616 assert_eq!(reaction_glyph("heart"), reaction_glyph("\u{2764}\u{FE0F}"));
617 assert_eq!(api_reaction(&reaction_glyph("heart")), "\u{2764}\u{FE0F}");
618 assert_eq!(api_reaction(&reaction_glyph("like")), "\u{1F44D}");
601 }
619 }
602
620
603 #[test]
621 #[test]
crates/app/src/views/conversation.rs +7 −4
@@ -30,9 +30,10 @@ use crate::read_state::{ReadTrigger, plan_read};
30 30 use crate::render::Block;
31 31 use crate::render::blocks::Inline;
32 32 use crate::rows::{
33 Delivery, LocalImage, MessageRow, Receipt, Row, RowContext, Series, StartInfo, assign_series,
34 changed_indices, diff_keys, flat_rows, message_text, placeholder_rows, reaction_type_for,
35 reply_excerpt, thread_list_rows, thread_rows, trailing_skeleton,
33 Delivery, LocalImage, MessageRow, Receipt, Row, RowContext, Series, StartInfo, api_reaction,
34 assign_series, changed_indices, diff_keys, flat_rows, message_text, placeholder_rows,
35 reaction_glyph, reaction_type_for, reply_excerpt, thread_list_rows, thread_rows,
36 trailing_skeleton,
36 37 };
37 38 use crate::runtime;
38 39 use crate::sidebar_model::{AvatarSpec, Face};
@@ -1557,6 +1558,7 @@ impl ConversationView {
1557 1558 return;
1558 1559 };
1559 1560 let reaction_type = reaction_type_for(glyph);
1561 let wanted = reaction_glyph(glyph);
1560 1562 let state = self.app.read(cx);
1561 1563 let (mode, engine, store) = (state.mode, state.engine.clone(), state.store.clone());
1562 1564 let my_user_id = self.row_context(cx).my_user_id;
@@ -1569,7 +1571,7 @@ impl ConversationView {
1569 1571 };
1570 1572 let mut reactions = teams_core::reactions(&record);
1571 1573 let mine = |reaction: &teams_core::ReactionInfo| {
1572 reaction.reaction_type == reaction_type
1574 reaction_glyph(&reaction.reaction_type) == wanted
1573 1575 && my_user_id.is_some()
1574 1576 && reaction.user_id == my_user_id
1575 1577 };
@@ -1594,6 +1596,7 @@ impl ConversationView {
1594 1596 return;
1595 1597 };
1596 1598 let message_id = message_id.to_owned();
1599 let reaction_type = api_reaction(&wanted);
1597 1600 let receiver = runtime::spawn(async move {
1598 1601 if remove {
1599 1602 engine
@@ -30,9 +30,10 @@ use crate::read_state::{ReadTrigger, plan_read};
30use crate::render::Block;
30use crate::render::Block;
31use crate::render::blocks::Inline;
31use crate::render::blocks::Inline;
32use crate::rows::{
32use crate::rows::{
33 Delivery, LocalImage, MessageRow, Receipt, Row, RowContext, Series, StartInfo, assign_series,
33 Delivery, LocalImage, MessageRow, Receipt, Row, RowContext, Series, StartInfo, api_reaction,
34 changed_indices, diff_keys, flat_rows, message_text, placeholder_rows, reaction_type_for,
34 assign_series, changed_indices, diff_keys, flat_rows, message_text, placeholder_rows,
35 reply_excerpt, thread_list_rows, thread_rows, trailing_skeleton,
35 reaction_glyph, reaction_type_for, reply_excerpt, thread_list_rows, thread_rows,
36 trailing_skeleton,
36};
37};
37use crate::runtime;
38use crate::runtime;
38use crate::sidebar_model::{AvatarSpec, Face};
39use crate::sidebar_model::{AvatarSpec, Face};
@@ -1557,6 +1558,7 @@ impl ConversationView {
1557 return;
1558 return;
1558 };
1559 };
1559 let reaction_type = reaction_type_for(glyph);
1560 let reaction_type = reaction_type_for(glyph);
1561 let wanted = reaction_glyph(glyph);
1560 let state = self.app.read(cx);
1562 let state = self.app.read(cx);
1561 let (mode, engine, store) = (state.mode, state.engine.clone(), state.store.clone());
1563 let (mode, engine, store) = (state.mode, state.engine.clone(), state.store.clone());
1562 let my_user_id = self.row_context(cx).my_user_id;
1564 let my_user_id = self.row_context(cx).my_user_id;
@@ -1569,7 +1571,7 @@ impl ConversationView {
1569 };
1571 };
1570 let mut reactions = teams_core::reactions(&record);
1572 let mut reactions = teams_core::reactions(&record);
1571 let mine = |reaction: &teams_core::ReactionInfo| {
1573 let mine = |reaction: &teams_core::ReactionInfo| {
1572 reaction.reaction_type == reaction_type
1574 reaction_glyph(&reaction.reaction_type) == wanted
1573 && my_user_id.is_some()
1575 && my_user_id.is_some()
1574 && reaction.user_id == my_user_id
1576 && reaction.user_id == my_user_id
1575 };
1577 };
@@ -1594,6 +1596,7 @@ impl ConversationView {
1594 return;
1596 return;
1595 };
1597 };
1596 let message_id = message_id.to_owned();
1598 let message_id = message_id.to_owned();
1599 let reaction_type = api_reaction(&wanted);
1597 let receiver = runtime::spawn(async move {
1600 let receiver = runtime::spawn(async move {
1598 if remove {
1601 if remove {
1599 engine
1602 engine