BlueGit

ict rusty-teams

Merge commit 'd19d4dfb' into kvt/integratie

# Conflicts:
#	KVT-FORK.md

hephaestus

Authored 2026-11-28 · 2 days ago

Hash
898ff63bd1b8456a7e71ebc24805c99ff72ca271
10 files changed +457 −24
KVT-FORK.md +13 −0
@@ -343,8 +343,21 @@ Merge-tip: de haak in `title_bar.rs` van gpui-component is de nieuwe methode en
343 343 Windows-tak van `on_double_click`. Blijft die bij een upstream-update weg, zet hem terug
344 344 en houd `system_window_controls(false)` in onze titelbalk.
345 345
346 ### Custom emoji in reactiepillen — upstream-kandidaat
347
348 Graph levert een custom reactie als `reactionType: "custom"` met `displayName` en `reactionContentUrl`.
349 De fork bewaarde alleen het type, waardoor de pil de afgekorte tekst "custo" toonde in plaats van het plaatje.
350 Dit is geen KVT-specifiek gedrag: dezelfde Graph-payload geldt voor elke tenant. Geschikt om naar upstream te sturen.
351
352 | | |
353 |---|---|
354 | Wat | Custom emoji-reacties herkennen (Graph-velden en chatsvc-sleutel `naam;objectid`) en als plaatje tonen; nooit de ruwe sleutel in de pil |
355 | Eigen bestanden | — |
356 | Upstream aangeraakt | `crates/graph/src/models.rs`, `crates/core/src/mapping.rs`, `crates/chatsvc/src/reactions.rs`, `crates/chatsvc/src/links.rs`, `crates/app-state/src/rows.rs`, `crates/app-state/src/reaction_model.rs`, `crates/app/src/views/reaction_pills.rs`, `crates/app-base/locales/app.yml` |
357
346 358 ## Eigen modules in het kort
347 359
360
348 361 | Pad | Rol |
349 362 |---|---|
350 363 | `crates/app-base/src/theme/kvt.rs` | Palet, WCAG-tests, DINPro-detectie |
@@ -343,8 +343,21 @@ Merge-tip: de haak in `title_bar.rs` van gpui-component is de nieuwe methode en
343Windows-tak van `on_double_click`. Blijft die bij een upstream-update weg, zet hem terug
343Windows-tak van `on_double_click`. Blijft die bij een upstream-update weg, zet hem terug
344en houd `system_window_controls(false)` in onze titelbalk.
344en houd `system_window_controls(false)` in onze titelbalk.
345
345
346### Custom emoji in reactiepillen — upstream-kandidaat
347
348Graph levert een custom reactie als `reactionType: "custom"` met `displayName` en `reactionContentUrl`.
349De fork bewaarde alleen het type, waardoor de pil de afgekorte tekst "custo" toonde in plaats van het plaatje.
350Dit is geen KVT-specifiek gedrag: dezelfde Graph-payload geldt voor elke tenant. Geschikt om naar upstream te sturen.
351
352| | |
353|---|---|
354| Wat | Custom emoji-reacties herkennen (Graph-velden en chatsvc-sleutel `naam;objectid`) en als plaatje tonen; nooit de ruwe sleutel in de pil |
355| Eigen bestanden | — |
356| Upstream aangeraakt | `crates/graph/src/models.rs`, `crates/core/src/mapping.rs`, `crates/chatsvc/src/reactions.rs`, `crates/chatsvc/src/links.rs`, `crates/app-state/src/rows.rs`, `crates/app-state/src/reaction_model.rs`, `crates/app/src/views/reaction_pills.rs`, `crates/app-base/locales/app.yml` |
357
346## Eigen modules in het kort
358## Eigen modules in het kort
347
359
360
348| Pad | Rol |
361| Pad | Rol |
349|---|---|
362|---|---|
350| `crates/app-base/src/theme/kvt.rs` | Palet, WCAG-tests, DINPro-detectie |
363| `crates/app-base/src/theme/kvt.rs` | Palet, WCAG-tests, DINPro-detectie |
crates/app-base/locales/app.yml +7 −0
@@ -109,6 +109,13 @@ notice:
109 109 en: "Something went wrong: %{detail}"
110 110 de: "Etwas ist schiefgelaufen: %{detail}"
111 111 nl: "Er ging iets mis: %{detail}"
112 reaction:
113 custom_emoji:
114 en: Custom emoji
115 de: Organisations-Emoji
116 nl: Organisatie-emoji
117
118
112 119 settings:
113 120 search:
114 121 no_results:
@@ -109,6 +109,13 @@ notice:
109 en: "Something went wrong: %{detail}"
109 en: "Something went wrong: %{detail}"
110 de: "Etwas ist schiefgelaufen: %{detail}"
110 de: "Etwas ist schiefgelaufen: %{detail}"
111 nl: "Er ging iets mis: %{detail}"
111 nl: "Er ging iets mis: %{detail}"
112reaction:
113 custom_emoji:
114 en: Custom emoji
115 de: Organisations-Emoji
116 nl: Organisatie-emoji
117
118
112settings:
119settings:
113 search:
120 search:
114 no_results:
121 no_results:
crates/app-state/src/reaction_model.rs +16 −2
@@ -1,6 +1,6 @@
1 1 use std::fmt::Display;
2 2
3 use app_base::ui_locale::tr_with;
3 use app_base::ui_locale::{tr, tr_with};
4 4 use chrono::{DateTime, Datelike, TimeZone, Utc};
5 5
6 6 use crate::rows::ReactionChip;
@@ -57,7 +57,21 @@ pub fn chip_tooltip(chip: &ReactionChip) -> String {
57 57 .iter()
58 58 .map(|reactor| reactor.name.as_str())
59 59 .collect();
60 tooltip_text(&names)
60 let people = tooltip_text(&names);
61 match emoji_tooltip_name(chip) {
62 Some(name) if people.is_empty() => name,
63 Some(name) => format!("{name}\n{people}"),
64 None => people,
65 }
66 }
67
68 fn emoji_tooltip_name(chip: &ReactionChip) -> Option<String> {
69 chatsvc::custom_emoji_display_name(&chip.reaction_type)
70 .or_else(|| chatsvc::custom_emoji_display_name(&chip.glyph()))
71 .or_else(|| {
72 chatsvc::hides_raw_reaction_key(&chip.reaction_type)
73 .then(|| tr("reaction.custom_emoji"))
74 })
61 75 }
62 76
63 77 pub fn reaction_time_label<Zone>(time: DateTime<Utc>, now: &DateTime<Zone>) -> String
@@ -1,6 +1,6 @@
1use std::fmt::Display;
1use std::fmt::Display;
2
2
3use app_base::ui_locale::tr_with;
3use app_base::ui_locale::{tr, tr_with};
4use chrono::{DateTime, Datelike, TimeZone, Utc};
4use chrono::{DateTime, Datelike, TimeZone, Utc};
5
5
6use crate::rows::ReactionChip;
6use crate::rows::ReactionChip;
@@ -57,7 +57,21 @@ pub fn chip_tooltip(chip: &ReactionChip) -> String {
57 .iter()
57 .iter()
58 .map(|reactor| reactor.name.as_str())
58 .map(|reactor| reactor.name.as_str())
59 .collect();
59 .collect();
60 tooltip_text(&names)
60 let people = tooltip_text(&names);
61 match emoji_tooltip_name(chip) {
62 Some(name) if people.is_empty() => name,
63 Some(name) => format!("{name}\n{people}"),
64 None => people,
65 }
66}
67
68fn emoji_tooltip_name(chip: &ReactionChip) -> Option<String> {
69 chatsvc::custom_emoji_display_name(&chip.reaction_type)
70 .or_else(|| chatsvc::custom_emoji_display_name(&chip.glyph()))
71 .or_else(|| {
72 chatsvc::hides_raw_reaction_key(&chip.reaction_type)
73 .then(|| tr("reaction.custom_emoji"))
74 })
61}
75}
62
76
63pub fn reaction_time_label<Zone>(time: DateTime<Utc>, now: &DateTime<Zone>) -> String
77pub fn reaction_time_label<Zone>(time: DateTime<Utc>, now: &DateTime<Zone>) -> String
crates/app-state/src/rows.rs +34 −4
@@ -60,10 +60,13 @@ impl ReactionChip {
60 60
61 61 /// Text for places without images: the org emoji's name instead of its raw key.
62 62 pub fn reaction_text(reaction_type: &str) -> String {
63 match chatsvc::custom_emoji(reaction_type) {
64 Some(emoji) => format!(":{}:", emoji.name),
65 None => reaction_glyph(reaction_type),
63 if let Some(name) = chatsvc::custom_emoji_display_name(reaction_type) {
64 return format!(":{name}:");
66 65 }
66 if chatsvc::hides_raw_reaction_key(reaction_type) {
67 return app_base::ui_locale::tr("reaction.custom_emoji");
68 }
69 reaction_glyph(reaction_type)
67 70 }
68 71
69 72 pub fn custom_emoji_image(reaction_type: &str) -> Option<ImageRef> {
@@ -514,6 +517,16 @@ pub fn apply_pending_reactions(
514 517 }
515 518 }
516 519
520 fn visible_reaction_label(reaction_type: &str, shown: &str) -> String {
521 if let Some(name) = chatsvc::custom_emoji_display_name(reaction_type) {
522 return format!(":{name}:");
523 }
524 if chatsvc::hides_raw_reaction_key(reaction_type) || chatsvc::hides_raw_reaction_key(shown) {
525 return String::new();
526 }
527 shown.to_owned()
528 }
529
517 530 pub fn reaction_chips(reactions: &[ReactionInfo], context: &RowContext) -> Vec<ReactionChip> {
518 531 let my_user_id = context.my_user_id.as_deref();
519 532 let mut chips: Vec<ReactionChip> = Vec::new();
@@ -553,7 +566,7 @@ pub fn reaction_chips(reactions: &[ReactionInfo], context: &RowContext) -> Vec<R
553 566 });
554 567 }
555 568 for (chip, shown) in chips.iter_mut().zip(variants) {
556 chip.label = shown.concat();
569 chip.label = visible_reaction_label(&chip.reaction_type, &shown.concat());
557 570 }
558 571 chips
559 572 }
@@ -1411,6 +1424,23 @@ mod tests {
1411 1424 .ends_with("/0-wcde-d3-5f5e4f463d6bb959b08614fd1d9680b8/views/imgt2_anim")
1412 1425 );
1413 1426 assert_eq!(custom_emoji_image("like"), None);
1427 assert_eq!(reaction_text("custom:tsignal"), ":tsignal:");
1428 assert_ne!(reaction_text("custom"), "custom");
1429 let hosted = concat!(
1430 "https://graph.microsoft.com/v1.0/teams/t/channels/c/messages/1/hostedContents/",
1431 "aWQ9MC13dWstZDItZjM4MjU3YzBmYmEyZDI5ODFlYzJhMzY4YzVjZjE4NTMsdHlwZT0xLHVybD0=/",
1432 "$value",
1433 );
1434 let from_graph =
1435 chatsvc::custom_reaction_key("custom", Some("tsignal"), Some(hosted), None)
1436 .expect("key");
1437 assert_eq!(reaction_text(&from_graph), ":tsignal:");
1438 let image = custom_emoji_image(&from_graph).expect("graph image");
1439 assert!(
1440 image
1441 .url
1442 .ends_with("/0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853/views/imgt2_anim")
1443 );
1414 1444 }
1415 1445
1416 1446 #[test]
@@ -60,10 +60,13 @@ impl ReactionChip {
60
60
61/// Text for places without images: the org emoji's name instead of its raw key.
61/// Text for places without images: the org emoji's name instead of its raw key.
62pub fn reaction_text(reaction_type: &str) -> String {
62pub fn reaction_text(reaction_type: &str) -> String {
63 match chatsvc::custom_emoji(reaction_type) {
63 if let Some(name) = chatsvc::custom_emoji_display_name(reaction_type) {
64 Some(emoji) => format!(":{}:", emoji.name),
64 return format!(":{name}:");
65 None => reaction_glyph(reaction_type),
66 }
65 }
66 if chatsvc::hides_raw_reaction_key(reaction_type) {
67 return app_base::ui_locale::tr("reaction.custom_emoji");
68 }
69 reaction_glyph(reaction_type)
67}
70}
68
71
69pub fn custom_emoji_image(reaction_type: &str) -> Option<ImageRef> {
72pub fn custom_emoji_image(reaction_type: &str) -> Option<ImageRef> {
@@ -514,6 +517,16 @@ pub fn apply_pending_reactions(
514 }
517 }
515}
518}
516
519
520fn visible_reaction_label(reaction_type: &str, shown: &str) -> String {
521 if let Some(name) = chatsvc::custom_emoji_display_name(reaction_type) {
522 return format!(":{name}:");
523 }
524 if chatsvc::hides_raw_reaction_key(reaction_type) || chatsvc::hides_raw_reaction_key(shown) {
525 return String::new();
526 }
527 shown.to_owned()
528}
529
517pub fn reaction_chips(reactions: &[ReactionInfo], context: &RowContext) -> Vec<ReactionChip> {
530pub fn reaction_chips(reactions: &[ReactionInfo], context: &RowContext) -> Vec<ReactionChip> {
518 let my_user_id = context.my_user_id.as_deref();
531 let my_user_id = context.my_user_id.as_deref();
519 let mut chips: Vec<ReactionChip> = Vec::new();
532 let mut chips: Vec<ReactionChip> = Vec::new();
@@ -553,7 +566,7 @@ pub fn reaction_chips(reactions: &[ReactionInfo], context: &RowContext) -> Vec<R
553 });
566 });
554 }
567 }
555 for (chip, shown) in chips.iter_mut().zip(variants) {
568 for (chip, shown) in chips.iter_mut().zip(variants) {
556 chip.label = shown.concat();
569 chip.label = visible_reaction_label(&chip.reaction_type, &shown.concat());
557 }
570 }
558 chips
571 chips
559}
572}
@@ -1411,6 +1424,23 @@ mod tests {
1411 .ends_with("/0-wcde-d3-5f5e4f463d6bb959b08614fd1d9680b8/views/imgt2_anim")
1424 .ends_with("/0-wcde-d3-5f5e4f463d6bb959b08614fd1d9680b8/views/imgt2_anim")
1412 );
1425 );
1413 assert_eq!(custom_emoji_image("like"), None);
1426 assert_eq!(custom_emoji_image("like"), None);
1427 assert_eq!(reaction_text("custom:tsignal"), ":tsignal:");
1428 assert_ne!(reaction_text("custom"), "custom");
1429 let hosted = concat!(
1430 "https://graph.microsoft.com/v1.0/teams/t/channels/c/messages/1/hostedContents/",
1431 "aWQ9MC13dWstZDItZjM4MjU3YzBmYmEyZDI5ODFlYzJhMzY4YzVjZjE4NTMsdHlwZT0xLHVybD0=/",
1432 "$value",
1433 );
1434 let from_graph =
1435 chatsvc::custom_reaction_key("custom", Some("tsignal"), Some(hosted), None)
1436 .expect("key");
1437 assert_eq!(reaction_text(&from_graph), ":tsignal:");
1438 let image = custom_emoji_image(&from_graph).expect("graph image");
1439 assert!(
1440 image
1441 .url
1442 .ends_with("/0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853/views/imgt2_anim")
1443 );
1414 }
1444 }
1415
1445
1416 #[test]
1446 #[test]
crates/app/src/views/reaction_pills.rs +24 −0
@@ -78,8 +78,32 @@ fn faces_width(count: usize) -> f32 {
78 78 diameter + count.saturating_sub(1) as f32 * (diameter - FACE_OVERLAP)
79 79 }
80 80
81 fn generic_custom_emoji(size: f32) -> AnyElement {
82 let glyph = (size * 0.7).round().max(8.);
83 div()
84 .size(px(size))
85 .flex_none()
86 .rounded(px((size * 0.25).round().max(2.)))
87 .border_1()
88 .border_color(theme::border_strong())
89 .flex()
90 .items_center()
91 .justify_center()
92 .text_size(px(glyph))
93 .line_height(px(size))
94 .text_color(theme::text_muted())
95 .child("☺")
96 .into_any_element()
97 }
98
81 99 fn reaction_emoji(glyph: &str, label: &str, size: f32, directory: &Directory) -> AnyElement {
82 100 let Some(image) = custom_emoji_image(glyph) else {
101 if chatsvc::hides_raw_reaction_key(glyph)
102 || chatsvc::hides_raw_reaction_key(label)
103 || label.is_empty() && chatsvc::is_custom_reaction_type(glyph)
104 {
105 return generic_custom_emoji(size);
106 }
83 107 return div()
84 108 .flex_none()
85 109 .h(px(size))
@@ -78,8 +78,32 @@ fn faces_width(count: usize) -> f32 {
78 diameter + count.saturating_sub(1) as f32 * (diameter - FACE_OVERLAP)
78 diameter + count.saturating_sub(1) as f32 * (diameter - FACE_OVERLAP)
79}
79}
80
80
81fn generic_custom_emoji(size: f32) -> AnyElement {
82 let glyph = (size * 0.7).round().max(8.);
83 div()
84 .size(px(size))
85 .flex_none()
86 .rounded(px((size * 0.25).round().max(2.)))
87 .border_1()
88 .border_color(theme::border_strong())
89 .flex()
90 .items_center()
91 .justify_center()
92 .text_size(px(glyph))
93 .line_height(px(size))
94 .text_color(theme::text_muted())
95 .child("☺")
96 .into_any_element()
97}
98
81fn reaction_emoji(glyph: &str, label: &str, size: f32, directory: &Directory) -> AnyElement {
99fn reaction_emoji(glyph: &str, label: &str, size: f32, directory: &Directory) -> AnyElement {
82 let Some(image) = custom_emoji_image(glyph) else {
100 let Some(image) = custom_emoji_image(glyph) else {
101 if chatsvc::hides_raw_reaction_key(glyph)
102 || chatsvc::hides_raw_reaction_key(label)
103 || label.is_empty() && chatsvc::is_custom_reaction_type(glyph)
104 {
105 return generic_custom_emoji(size);
106 }
83 return div()
107 return div()
84 .flex_none()
108 .flex_none()
85 .h(px(size))
109 .h(px(size))
crates/chatsvc/src/lib.rs +3 −2
@@ -104,7 +104,7 @@ pub use language_settings::{
104 104 };
105 105 pub use links::{
106 106 LinkImage, LinkInfo, MessageLinks, ams_full_size_url, hosted_content_image_url,
107 is_ams_image_url, is_link_image_url,
107 hosted_content_object_id, is_ams_image_url, is_link_image_url,
108 108 };
109 109 pub use mask::mask_conversation_id;
110 110 pub use members::{
@@ -123,7 +123,8 @@ pub use presence::{
123 123 error_status, is_endpoint_missing,
124 124 };
125 125 pub use reactions::{
126 CustomEmoji, custom_emoji, emotion_glyph, emotion_key, emotion_keys, insert_skin_tone,
126 CustomEmoji, custom_emoji, custom_emoji_display_name, custom_reaction_key, emotion_glyph,
127 emotion_key, emotion_keys, hides_raw_reaction_key, insert_skin_tone, is_custom_reaction_type,
127 128 reaction_glyph_for_key, reaction_key, reaction_keys,
128 129 };
129 130 pub use read_horizon::ReadHorizon;
@@ -104,7 +104,7 @@ pub use language_settings::{
104};
104};
105pub use links::{
105pub use links::{
106 LinkImage, LinkInfo, MessageLinks, ams_full_size_url, hosted_content_image_url,
106 LinkImage, LinkInfo, MessageLinks, ams_full_size_url, hosted_content_image_url,
107 is_ams_image_url, is_link_image_url,
107 hosted_content_object_id, is_ams_image_url, is_link_image_url,
108};
108};
109pub use mask::mask_conversation_id;
109pub use mask::mask_conversation_id;
110pub use members::{
110pub use members::{
@@ -123,7 +123,8 @@ pub use presence::{
123 error_status, is_endpoint_missing,
123 error_status, is_endpoint_missing,
124};
124};
125pub use reactions::{
125pub use reactions::{
126 CustomEmoji, custom_emoji, emotion_glyph, emotion_key, emotion_keys, insert_skin_tone,
126 CustomEmoji, custom_emoji, custom_emoji_display_name, custom_reaction_key, emotion_glyph,
127 emotion_key, emotion_keys, hides_raw_reaction_key, insert_skin_tone, is_custom_reaction_type,
127 reaction_glyph_for_key, reaction_key, reaction_keys,
128 reaction_glyph_for_key, reaction_key, reaction_keys,
128};
129};
129pub use read_horizon::ReadHorizon;
130pub use read_horizon::ReadHorizon;
crates/chatsvc/src/reactions.rs +261 −13
@@ -145,26 +145,185 @@ pub fn emotion_key(glyph: &str) -> Option<&'static str> {
145 145 emotion_keys(glyph).first().copied()
146 146 }
147 147
148 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
149 pub struct CustomEmoji<'a> {
150 pub name: &'a str,
151 pub object_id: &'a str,
148 const CUSTOM_TYPE: &str = "custom";
149 const CUSTOM_UNDERSCORE: &str = "custom_";
150 const CUSTOM_COLON: &str = "custom:";
151
152 #[derive(Debug, Clone, PartialEq, Eq)]
153 pub struct CustomEmoji {
154 pub name: String,
155 pub object_id: String,
152 156 }
153 157
154 impl CustomEmoji<'_> {
158 impl CustomEmoji {
159 pub fn key(&self) -> String {
160 format!("{}{CUSTOM_EMOJI_SEPARATOR}{}", self.name, self.object_id)
161 }
162
155 163 pub fn image_url(&self) -> String {
156 164 format!("{AMS_OBJECTS_BASE}{}{CUSTOM_EMOJI_VIEW}", self.object_id)
157 165 }
166
167 /// The name to show in a tooltip or as `:name:`. `None` when we only have a placeholder.
168 pub fn display_name(&self) -> Option<&str> {
169 let name = self.name.trim();
170 (!name.is_empty() && !name.eq_ignore_ascii_case(CUSTOM_TYPE)).then_some(name)
171 }
158 172 }
159 173
160 /// `absolute-cinema;0-wcde-d3-5f5e...`: an org emoji, name and AMS object of its image.
161 pub fn custom_emoji(key: &str) -> Option<CustomEmoji<'_>> {
162 let (name, object_id) = key.split_once(CUSTOM_EMOJI_SEPARATOR)?;
163 let valid_object = !object_id.is_empty()
164 && object_id
165 .chars()
166 .all(|character| character.is_ascii_alphanumeric() || character == '-');
167 (!name.is_empty() && valid_object).then_some(CustomEmoji { name, object_id })
174 /// An org custom emoji hidden in a reaction key.
175 ///
176 /// Known shapes:
177 /// - `name;objectId` (chat service emotions)
178 /// - a Graph `hostedContents/...` URL whose id is `id={objectId},type=1,url=`
179 /// - an AMS object URL
180 /// - `custom_{objectId}` or a bare object id
181 pub fn custom_emoji(key: &str) -> Option<CustomEmoji> {
182 let key = key.trim();
183 if let Some((name, object_id)) = key.split_once(CUSTOM_EMOJI_SEPARATOR) {
184 let object_id = object_id
185 .split([CUSTOM_EMOJI_SEPARATOR, '|'])
186 .next()
187 .unwrap_or(object_id)
188 .trim();
189 let name = name
190 .strip_prefix(CUSTOM_UNDERSCORE)
191 .or_else(|| name.strip_prefix(CUSTOM_COLON))
192 .unwrap_or(name)
193 .trim();
194 if !name.is_empty() && crate::links::is_ams_object_id(object_id) {
195 return Some(CustomEmoji {
196 name: name.to_owned(),
197 object_id: object_id.to_owned(),
198 });
199 }
200 }
201 if let Some(object_id) = crate::links::hosted_content_object_id(key) {
202 return Some(CustomEmoji {
203 name: CUSTOM_TYPE.to_owned(),
204 object_id,
205 });
206 }
207 if let Some(object_id) = crate::links::object_id_from_ams_path(key) {
208 return Some(CustomEmoji {
209 name: CUSTOM_TYPE.to_owned(),
210 object_id: object_id.to_owned(),
211 });
212 }
213 if let Some(object_id) = key
214 .strip_prefix(CUSTOM_UNDERSCORE)
215 .or_else(|| key.strip_prefix(CUSTOM_COLON))
216 .map(str::trim)
217 .filter(|id| crate::links::is_ams_object_id(id))
218 {
219 return Some(CustomEmoji {
220 name: CUSTOM_TYPE.to_owned(),
221 object_id: object_id.to_owned(),
222 });
223 }
224 crate::links::is_ams_object_id(key).then(|| CustomEmoji {
225 name: CUSTOM_TYPE.to_owned(),
226 object_id: key.to_owned(),
227 })
228 }
229
230 /// Canonical `name;objectId` key from a Graph (or mixed) custom reaction payload.
231 ///
232 /// Graph stores `reactionType: "custom"` with the name and image in `displayName`
233 /// and `reactionContentUrl`. Returns `None` when this is not a custom reaction.
234 pub fn custom_reaction_key(
235 reaction_type: &str,
236 display_name: Option<&str>,
237 content_url: Option<&str>,
238 reaction_id: Option<&str>,
239 ) -> Option<String> {
240 let display_name = display_name.map(str::trim).filter(|name| !name.is_empty());
241 if let Some(emoji) = custom_emoji(reaction_type) {
242 let name = display_name
243 .or_else(|| emoji.display_name())
244 .unwrap_or(&emoji.name);
245 return Some(
246 CustomEmoji {
247 name: name.to_owned(),
248 object_id: emoji.object_id,
249 }
250 .key(),
251 );
252 }
253 let object_id = content_url
254 .and_then(crate::links::hosted_content_object_id)
255 .or_else(|| {
256 content_url
257 .and_then(crate::links::object_id_from_ams_path)
258 .map(str::to_owned)
259 })
260 .or_else(|| {
261 reaction_id
262 .map(str::trim)
263 .filter(|id| crate::links::is_ams_object_id(id))
264 .map(str::to_owned)
265 });
266 match (display_name, object_id) {
267 (Some(name), Some(object_id)) => Some(
268 CustomEmoji {
269 name: name.to_owned(),
270 object_id,
271 }
272 .key(),
273 ),
274 (None, Some(object_id)) if is_custom_reaction_type(reaction_type) => Some(
275 CustomEmoji {
276 name: CUSTOM_TYPE.to_owned(),
277 object_id,
278 }
279 .key(),
280 ),
281 (Some(name), None) if is_custom_reaction_type(reaction_type) => {
282 Some(format!("{CUSTOM_COLON}{name}"))
283 }
284 _ if is_custom_reaction_type(reaction_type) => Some(CUSTOM_TYPE.to_owned()),
285 _ => None,
286 }
287 }
288
289 pub fn is_custom_reaction_type(reaction_type: &str) -> bool {
290 let key = reaction_type.trim();
291 key.eq_ignore_ascii_case(CUSTOM_TYPE)
292 || key.starts_with(CUSTOM_UNDERSCORE)
293 || key.starts_with(CUSTOM_COLON)
294 || custom_emoji(key).is_some()
295 }
296
297 /// A reaction key that must not be drawn as text in a pill (`custom`, `name;id`, ...).
298 pub fn hides_raw_reaction_key(key: &str) -> bool {
299 if ["like", "heart", "laugh", "surprised", "sad", "angry"].contains(&key) {
300 return false;
301 }
302 if reaction_glyph_for_key(key).is_some() {
303 return false;
304 }
305 if key.chars().any(|character| !character.is_ascii()) {
306 return false;
307 }
308 is_custom_reaction_type(key)
309 || custom_emoji_display_name(key).is_some()
310 || crate::links::is_ams_object_id(key)
311 || key.contains(CUSTOM_EMOJI_SEPARATOR)
312 }
313
314 pub fn custom_emoji_display_name(key: &str) -> Option<String> {
315 if let Some(name) = custom_emoji(key)
316 .as_ref()
317 .and_then(CustomEmoji::display_name)
318 {
319 return Some(name.to_owned());
320 }
321 let key = key.trim();
322 key.strip_prefix(CUSTOM_COLON)
323 .or_else(|| key.strip_prefix(CUSTOM_UNDERSCORE))
324 .map(str::trim)
325 .filter(|name| !name.is_empty() && !crate::links::is_ams_object_id(name))
326 .map(str::to_owned)
168 327 }
169 328
170 329 #[cfg(test)]
@@ -183,6 +342,95 @@ mod tests {
183 342 assert_eq!(custom_emoji("like"), None);
184 343 assert_eq!(custom_emoji("x;../evil"), None);
185 344 assert_eq!(custom_emoji(";0-wcde-d3-1"), None);
345 assert_eq!(custom_emoji("custom"), None);
346 }
347
348 #[test]
349 fn custom_emoji_keys_accept_graph_and_prefixed_variants() {
350 let object_id = "0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853";
351 let hosted = format!(
352 "https://graph.microsoft.com/v1.0/teams/t/channels/c/messages/1/hostedContents/{}/$value",
353 base64_id(object_id)
354 );
355 let from_url = custom_emoji(&hosted).expect("hosted content");
356 assert_eq!(from_url.object_id, object_id);
357 assert_eq!(
358 from_url.image_url(),
359 format!(
360 "https://de-prod.asyncgw.teams.microsoft.com/v1/objects/{object_id}/views/imgt2_anim"
361 )
362 );
363
364 let from_prefix = custom_emoji(&format!("custom_{object_id}")).expect("prefixed");
365 assert_eq!(from_prefix.object_id, object_id);
366
367 let from_bare = custom_emoji(object_id).expect("bare object id");
368 assert_eq!(from_bare.object_id, object_id);
369
370 let from_ams = custom_emoji(&format!(
371 "https://de-prod.asyncgw.teams.microsoft.com/v1/objects/{object_id}/views/imgt2_anim"
372 ))
373 .expect("ams url");
374 assert_eq!(from_ams.object_id, object_id);
375 }
376
377 #[test]
378 fn graph_custom_reaction_payloads_become_a_name_and_object_key() {
379 let object_id = "0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853";
380 let hosted = format!(
381 "https://graph.microsoft.com/v1.0/teams/t/channels/c/messages/1/hostedContents/{}/$value",
382 base64_id(object_id)
383 );
384 assert_eq!(
385 custom_reaction_key("custom", Some("tsignal"), Some(&hosted), None).as_deref(),
386 Some("tsignal;0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853")
387 );
388 assert_eq!(
389 custom_reaction_key("custom", Some("party-parrot"), None, Some(object_id)).as_deref(),
390 Some("party-parrot;0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853")
391 );
392 assert_eq!(
393 custom_reaction_key("custom", Some("tsignal"), None, None).as_deref(),
394 Some("custom:tsignal")
395 );
396 assert_eq!(
397 custom_reaction_key("custom", None, None, None).as_deref(),
398 Some("custom")
399 );
400 assert_eq!(custom_reaction_key("like", None, None, None), None);
401 assert_eq!(
402 custom_reaction_key(
403 "absolute-cinema;0-wcde-d3-5f5e4f463d6bb959b08614fd1d9680b8",
404 None,
405 None,
406 None
407 )
408 .as_deref(),
409 Some("absolute-cinema;0-wcde-d3-5f5e4f463d6bb959b08614fd1d9680b8")
410 );
411 assert!(hides_raw_reaction_key("custom"));
412 assert!(hides_raw_reaction_key("custom:tsignal"));
413 assert!(hides_raw_reaction_key(
414 "absolute-cinema;0-wcde-d3-5f5e4f463d6bb959b08614fd1d9680b8"
415 ));
416 assert!(!hides_raw_reaction_key("like"));
417 assert!(!hides_raw_reaction_key("\u{1F44D}"));
418 assert_eq!(
419 custom_emoji_display_name("custom:tsignal").as_deref(),
420 Some("tsignal")
421 );
422 assert_eq!(
423 custom_emoji_display_name("tsignal;0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853")
424 .as_deref(),
425 Some("tsignal")
426 );
427 }
428
429 fn base64_id(object_id: &str) -> String {
430 base64::Engine::encode(
431 &base64::engine::general_purpose::STANDARD,
432 format!("id={object_id},type=1,url="),
433 )
186 434 }
187 435
188 436 #[test]
@@ -145,26 +145,185 @@ pub fn emotion_key(glyph: &str) -> Option<&'static str> {
145 emotion_keys(glyph).first().copied()
145 emotion_keys(glyph).first().copied()
146}
146}
147
147
148#[derive(Debug, Clone, Copy, PartialEq, Eq)]
148const CUSTOM_TYPE: &str = "custom";
149pub struct CustomEmoji<'a> {
149const CUSTOM_UNDERSCORE: &str = "custom_";
150 pub name: &'a str,
150const CUSTOM_COLON: &str = "custom:";
151 pub object_id: &'a str,
151
152#[derive(Debug, Clone, PartialEq, Eq)]
153pub struct CustomEmoji {
154 pub name: String,
155 pub object_id: String,
152}
156}
153
157
154impl CustomEmoji<'_> {
158impl CustomEmoji {
159 pub fn key(&self) -> String {
160 format!("{}{CUSTOM_EMOJI_SEPARATOR}{}", self.name, self.object_id)
161 }
162
155 pub fn image_url(&self) -> String {
163 pub fn image_url(&self) -> String {
156 format!("{AMS_OBJECTS_BASE}{}{CUSTOM_EMOJI_VIEW}", self.object_id)
164 format!("{AMS_OBJECTS_BASE}{}{CUSTOM_EMOJI_VIEW}", self.object_id)
157 }
165 }
166
167 /// The name to show in a tooltip or as `:name:`. `None` when we only have a placeholder.
168 pub fn display_name(&self) -> Option<&str> {
169 let name = self.name.trim();
170 (!name.is_empty() && !name.eq_ignore_ascii_case(CUSTOM_TYPE)).then_some(name)
171 }
158}
172}
159
173
160/// `absolute-cinema;0-wcde-d3-5f5e...`: an org emoji, name and AMS object of its image.
174/// An org custom emoji hidden in a reaction key.
161pub fn custom_emoji(key: &str) -> Option<CustomEmoji<'_>> {
175///
162 let (name, object_id) = key.split_once(CUSTOM_EMOJI_SEPARATOR)?;
176/// Known shapes:
163 let valid_object = !object_id.is_empty()
177/// - `name;objectId` (chat service emotions)
164 && object_id
178/// - a Graph `hostedContents/...` URL whose id is `id={objectId},type=1,url=`
165 .chars()
179/// - an AMS object URL
166 .all(|character| character.is_ascii_alphanumeric() || character == '-');
180/// - `custom_{objectId}` or a bare object id
167 (!name.is_empty() && valid_object).then_some(CustomEmoji { name, object_id })
181pub fn custom_emoji(key: &str) -> Option<CustomEmoji> {
182 let key = key.trim();
183 if let Some((name, object_id)) = key.split_once(CUSTOM_EMOJI_SEPARATOR) {
184 let object_id = object_id
185 .split([CUSTOM_EMOJI_SEPARATOR, '|'])
186 .next()
187 .unwrap_or(object_id)
188 .trim();
189 let name = name
190 .strip_prefix(CUSTOM_UNDERSCORE)
191 .or_else(|| name.strip_prefix(CUSTOM_COLON))
192 .unwrap_or(name)
193 .trim();
194 if !name.is_empty() && crate::links::is_ams_object_id(object_id) {
195 return Some(CustomEmoji {
196 name: name.to_owned(),
197 object_id: object_id.to_owned(),
198 });
199 }
200 }
201 if let Some(object_id) = crate::links::hosted_content_object_id(key) {
202 return Some(CustomEmoji {
203 name: CUSTOM_TYPE.to_owned(),
204 object_id,
205 });
206 }
207 if let Some(object_id) = crate::links::object_id_from_ams_path(key) {
208 return Some(CustomEmoji {
209 name: CUSTOM_TYPE.to_owned(),
210 object_id: object_id.to_owned(),
211 });
212 }
213 if let Some(object_id) = key
214 .strip_prefix(CUSTOM_UNDERSCORE)
215 .or_else(|| key.strip_prefix(CUSTOM_COLON))
216 .map(str::trim)
217 .filter(|id| crate::links::is_ams_object_id(id))
218 {
219 return Some(CustomEmoji {
220 name: CUSTOM_TYPE.to_owned(),
221 object_id: object_id.to_owned(),
222 });
223 }
224 crate::links::is_ams_object_id(key).then(|| CustomEmoji {
225 name: CUSTOM_TYPE.to_owned(),
226 object_id: key.to_owned(),
227 })
228}
229
230/// Canonical `name;objectId` key from a Graph (or mixed) custom reaction payload.
231///
232/// Graph stores `reactionType: "custom"` with the name and image in `displayName`
233/// and `reactionContentUrl`. Returns `None` when this is not a custom reaction.
234pub fn custom_reaction_key(
235 reaction_type: &str,
236 display_name: Option<&str>,
237 content_url: Option<&str>,
238 reaction_id: Option<&str>,
239) -> Option<String> {
240 let display_name = display_name.map(str::trim).filter(|name| !name.is_empty());
241 if let Some(emoji) = custom_emoji(reaction_type) {
242 let name = display_name
243 .or_else(|| emoji.display_name())
244 .unwrap_or(&emoji.name);
245 return Some(
246 CustomEmoji {
247 name: name.to_owned(),
248 object_id: emoji.object_id,
249 }
250 .key(),
251 );
252 }
253 let object_id = content_url
254 .and_then(crate::links::hosted_content_object_id)
255 .or_else(|| {
256 content_url
257 .and_then(crate::links::object_id_from_ams_path)
258 .map(str::to_owned)
259 })
260 .or_else(|| {
261 reaction_id
262 .map(str::trim)
263 .filter(|id| crate::links::is_ams_object_id(id))
264 .map(str::to_owned)
265 });
266 match (display_name, object_id) {
267 (Some(name), Some(object_id)) => Some(
268 CustomEmoji {
269 name: name.to_owned(),
270 object_id,
271 }
272 .key(),
273 ),
274 (None, Some(object_id)) if is_custom_reaction_type(reaction_type) => Some(
275 CustomEmoji {
276 name: CUSTOM_TYPE.to_owned(),
277 object_id,
278 }
279 .key(),
280 ),
281 (Some(name), None) if is_custom_reaction_type(reaction_type) => {
282 Some(format!("{CUSTOM_COLON}{name}"))
283 }
284 _ if is_custom_reaction_type(reaction_type) => Some(CUSTOM_TYPE.to_owned()),
285 _ => None,
286 }
287}
288
289pub fn is_custom_reaction_type(reaction_type: &str) -> bool {
290 let key = reaction_type.trim();
291 key.eq_ignore_ascii_case(CUSTOM_TYPE)
292 || key.starts_with(CUSTOM_UNDERSCORE)
293 || key.starts_with(CUSTOM_COLON)
294 || custom_emoji(key).is_some()
295}
296
297/// A reaction key that must not be drawn as text in a pill (`custom`, `name;id`, ...).
298pub fn hides_raw_reaction_key(key: &str) -> bool {
299 if ["like", "heart", "laugh", "surprised", "sad", "angry"].contains(&key) {
300 return false;
301 }
302 if reaction_glyph_for_key(key).is_some() {
303 return false;
304 }
305 if key.chars().any(|character| !character.is_ascii()) {
306 return false;
307 }
308 is_custom_reaction_type(key)
309 || custom_emoji_display_name(key).is_some()
310 || crate::links::is_ams_object_id(key)
311 || key.contains(CUSTOM_EMOJI_SEPARATOR)
312}
313
314pub fn custom_emoji_display_name(key: &str) -> Option<String> {
315 if let Some(name) = custom_emoji(key)
316 .as_ref()
317 .and_then(CustomEmoji::display_name)
318 {
319 return Some(name.to_owned());
320 }
321 let key = key.trim();
322 key.strip_prefix(CUSTOM_COLON)
323 .or_else(|| key.strip_prefix(CUSTOM_UNDERSCORE))
324 .map(str::trim)
325 .filter(|name| !name.is_empty() && !crate::links::is_ams_object_id(name))
326 .map(str::to_owned)
168}
327}
169
328
170#[cfg(test)]
329#[cfg(test)]
@@ -183,6 +342,95 @@ mod tests {
183 assert_eq!(custom_emoji("like"), None);
342 assert_eq!(custom_emoji("like"), None);
184 assert_eq!(custom_emoji("x;../evil"), None);
343 assert_eq!(custom_emoji("x;../evil"), None);
185 assert_eq!(custom_emoji(";0-wcde-d3-1"), None);
344 assert_eq!(custom_emoji(";0-wcde-d3-1"), None);
345 assert_eq!(custom_emoji("custom"), None);
346 }
347
348 #[test]
349 fn custom_emoji_keys_accept_graph_and_prefixed_variants() {
350 let object_id = "0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853";
351 let hosted = format!(
352 "https://graph.microsoft.com/v1.0/teams/t/channels/c/messages/1/hostedContents/{}/$value",
353 base64_id(object_id)
354 );
355 let from_url = custom_emoji(&hosted).expect("hosted content");
356 assert_eq!(from_url.object_id, object_id);
357 assert_eq!(
358 from_url.image_url(),
359 format!(
360 "https://de-prod.asyncgw.teams.microsoft.com/v1/objects/{object_id}/views/imgt2_anim"
361 )
362 );
363
364 let from_prefix = custom_emoji(&format!("custom_{object_id}")).expect("prefixed");
365 assert_eq!(from_prefix.object_id, object_id);
366
367 let from_bare = custom_emoji(object_id).expect("bare object id");
368 assert_eq!(from_bare.object_id, object_id);
369
370 let from_ams = custom_emoji(&format!(
371 "https://de-prod.asyncgw.teams.microsoft.com/v1/objects/{object_id}/views/imgt2_anim"
372 ))
373 .expect("ams url");
374 assert_eq!(from_ams.object_id, object_id);
375 }
376
377 #[test]
378 fn graph_custom_reaction_payloads_become_a_name_and_object_key() {
379 let object_id = "0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853";
380 let hosted = format!(
381 "https://graph.microsoft.com/v1.0/teams/t/channels/c/messages/1/hostedContents/{}/$value",
382 base64_id(object_id)
383 );
384 assert_eq!(
385 custom_reaction_key("custom", Some("tsignal"), Some(&hosted), None).as_deref(),
386 Some("tsignal;0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853")
387 );
388 assert_eq!(
389 custom_reaction_key("custom", Some("party-parrot"), None, Some(object_id)).as_deref(),
390 Some("party-parrot;0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853")
391 );
392 assert_eq!(
393 custom_reaction_key("custom", Some("tsignal"), None, None).as_deref(),
394 Some("custom:tsignal")
395 );
396 assert_eq!(
397 custom_reaction_key("custom", None, None, None).as_deref(),
398 Some("custom")
399 );
400 assert_eq!(custom_reaction_key("like", None, None, None), None);
401 assert_eq!(
402 custom_reaction_key(
403 "absolute-cinema;0-wcde-d3-5f5e4f463d6bb959b08614fd1d9680b8",
404 None,
405 None,
406 None
407 )
408 .as_deref(),
409 Some("absolute-cinema;0-wcde-d3-5f5e4f463d6bb959b08614fd1d9680b8")
410 );
411 assert!(hides_raw_reaction_key("custom"));
412 assert!(hides_raw_reaction_key("custom:tsignal"));
413 assert!(hides_raw_reaction_key(
414 "absolute-cinema;0-wcde-d3-5f5e4f463d6bb959b08614fd1d9680b8"
415 ));
416 assert!(!hides_raw_reaction_key("like"));
417 assert!(!hides_raw_reaction_key("\u{1F44D}"));
418 assert_eq!(
419 custom_emoji_display_name("custom:tsignal").as_deref(),
420 Some("tsignal")
421 );
422 assert_eq!(
423 custom_emoji_display_name("tsignal;0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853")
424 .as_deref(),
425 Some("tsignal")
426 );
427 }
428
429 fn base64_id(object_id: &str) -> String {
430 base64::Engine::encode(
431 &base64::engine::general_purpose::STANDARD,
432 format!("id={object_id},type=1,url="),
433 )
186 }
434 }
187
435
188 #[test]
436 #[test]
crates/core/src/mapping.rs +38 −1
@@ -280,7 +280,13 @@ fn quote_info(content: &str) -> Option<QuoteInfo> {
280 280
281 281 fn reaction_info(reaction: &Reaction) -> ReactionInfo {
282 282 ReactionInfo {
283 reaction_type: reaction.reaction_type.clone(),
283 reaction_type: chatsvc::custom_reaction_key(
284 &reaction.reaction_type,
285 reaction.display_name.as_deref(),
286 reaction.reaction_content_url.as_deref(),
287 reaction.reaction_id.as_deref(),
288 )
289 .unwrap_or_else(|| reaction.reaction_type.clone()),
284 290 user_id: reaction
285 291 .user
286 292 .as_ref()
@@ -671,4 +677,35 @@ mod tests {
671 677 assert!(!mentions_of(mentioned)[0].group);
672 678 }
673 679 }
680
681 #[test]
682 fn graph_custom_emoji_reactions_keep_their_name_and_object() {
683 let hosted = concat!(
684 "https://graph.microsoft.com/v1.0/teams/t/channels/c/messages/1/hostedContents/",
685 "aWQ9MC13dWstZDItZjM4MjU3YzBmYmEyZDI5ODFlYzJhMzY4YzVjZjE4NTMsdHlwZT0xLHVybD0=/",
686 "$value",
687 );
688 let message: Message = serde_json::from_value(json!({
689 "id": "m1",
690 "messageType": "message",
691 "createdDateTime": "2026-05-03T14:30:00Z",
692 "from": {"user": {"id": "u1", "displayName": "Ann"}},
693 "body": {"contentType": "html", "content": "<p>hi</p>"},
694 "reactions": [{
695 "reactionType": "custom",
696 "displayName": "tsignal",
697 "reactionContentUrl": hosted,
698 "createdDateTime": "2026-05-03T14:37:23.278Z",
699 "user": {"user": {"id": "u2", "displayName": "Bo"}},
700 }],
701 }))
702 .unwrap();
703 let record = message_record("c", &message).expect("record");
704 let reactions = crate::stored::reactions(&record);
705 assert_eq!(
706 reactions[0].reaction_type,
707 "tsignal;0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853"
708 );
709 assert_eq!(reactions[0].user_id.as_deref(), Some("u2"));
710 }
674 711 }
@@ -280,7 +280,13 @@ fn quote_info(content: &str) -> Option<QuoteInfo> {
280
280
281fn reaction_info(reaction: &Reaction) -> ReactionInfo {
281fn reaction_info(reaction: &Reaction) -> ReactionInfo {
282 ReactionInfo {
282 ReactionInfo {
283 reaction_type: reaction.reaction_type.clone(),
283 reaction_type: chatsvc::custom_reaction_key(
284 &reaction.reaction_type,
285 reaction.display_name.as_deref(),
286 reaction.reaction_content_url.as_deref(),
287 reaction.reaction_id.as_deref(),
288 )
289 .unwrap_or_else(|| reaction.reaction_type.clone()),
284 user_id: reaction
290 user_id: reaction
285 .user
291 .user
286 .as_ref()
292 .as_ref()
@@ -671,4 +677,35 @@ mod tests {
671 assert!(!mentions_of(mentioned)[0].group);
677 assert!(!mentions_of(mentioned)[0].group);
672 }
678 }
673 }
679 }
680
681 #[test]
682 fn graph_custom_emoji_reactions_keep_their_name_and_object() {
683 let hosted = concat!(
684 "https://graph.microsoft.com/v1.0/teams/t/channels/c/messages/1/hostedContents/",
685 "aWQ9MC13dWstZDItZjM4MjU3YzBmYmEyZDI5ODFlYzJhMzY4YzVjZjE4NTMsdHlwZT0xLHVybD0=/",
686 "$value",
687 );
688 let message: Message = serde_json::from_value(json!({
689 "id": "m1",
690 "messageType": "message",
691 "createdDateTime": "2026-05-03T14:30:00Z",
692 "from": {"user": {"id": "u1", "displayName": "Ann"}},
693 "body": {"contentType": "html", "content": "<p>hi</p>"},
694 "reactions": [{
695 "reactionType": "custom",
696 "displayName": "tsignal",
697 "reactionContentUrl": hosted,
698 "createdDateTime": "2026-05-03T14:37:23.278Z",
699 "user": {"user": {"id": "u2", "displayName": "Bo"}},
700 }],
701 }))
702 .unwrap();
703 let record = message_record("c", &message).expect("record");
704 let reactions = crate::stored::reactions(&record);
705 assert_eq!(
706 reactions[0].reaction_type,
707 "tsignal;0-wuk-d2-f38257c0fba2d2981ec2a368c5cf1853"
708 );
709 assert_eq!(reactions[0].user_id.as_deref(), Some("u2"));
710 }
674}
711}
crates/graph/src/models.rs +6 −0
@@ -112,6 +112,12 @@ pub struct Attachment {
112 112 #[serde(rename_all = "camelCase")]
113 113 pub struct Reaction {
114 114 pub reaction_type: String,
115 #[serde(default)]
116 pub display_name: Option<String>,
117 #[serde(default)]
118 pub reaction_content_url: Option<String>,
119 #[serde(default)]
120 pub reaction_id: Option<String>,
115 121 pub created_date_time: Option<DateTime<Utc>>,
116 122 pub user: Option<Sender>,
117 123 }
@@ -112,6 +112,12 @@ pub struct Attachment {
112#[serde(rename_all = "camelCase")]
112#[serde(rename_all = "camelCase")]
113pub struct Reaction {
113pub struct Reaction {
114 pub reaction_type: String,
114 pub reaction_type: String,
115 #[serde(default)]
116 pub display_name: Option<String>,
117 #[serde(default)]
118 pub reaction_content_url: Option<String>,
119 #[serde(default)]
120 pub reaction_id: Option<String>,
115 pub created_date_time: Option<DateTime<Utc>>,
121 pub created_date_time: Option<DateTime<Utc>>,
116 pub user: Option<Sender>,
122 pub user: Option<Sender>,
117}
123}