BlueGit

ict rusty-teams

fix(write-path): channel mentions in quote replies stay on Graph

- chatsvc channel mention shape is not verified against Teams; keep the known Graph path

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-04 · 3 weeks ago

Hash
0136594443b5f9319168eb03bb9c01016a049767
Parent
ec59d7a5
1 file changed +10 −24
crates/core/src/teams_quote.rs +10 −24
@@ -66,16 +66,14 @@ pub(crate) fn quote_reply_properties(
66 66 }
67 67
68 68 fn mention_entry(mention: &OutgoingMention) -> Option<Value> {
69 let (mri, mention_type) = match &mention.target {
70 MentionTarget::User { user_id } => (user_mri(user_id), "person"),
71 MentionTarget::Channel { channel_id } => (channel_id.clone(), "channel"),
72 MentionTarget::Team { .. } => return None,
69 let MentionTarget::User { user_id } = &mention.target else {
70 return None;
73 71 };
74 72 Some(json!({
75 73 "@type": MENTION_ITEMTYPE,
76 74 "itemid": mention.id.to_string(),
77 "mri": mri,
78 "mentionType": mention_type,
75 "mri": user_mri(user_id),
76 "mentionType": "person",
79 77 "displayName": mention.text,
80 78 }))
81 79 }
@@ -180,30 +178,18 @@ mod tests {
180 178 }
181 179
182 180 #[test]
183 fn a_channel_mention_points_at_the_channel_thread() {
184 let mentions = [mention(
185 1,
181 fn channel_and_team_mentions_have_no_chatsvc_shape() {
182 for target in [
186 183 MentionTarget::Channel {
187 184 channel_id: "19:c@thread.tacv2".into(),
188 185 },
189 )];
190 let properties = quote_reply_properties(&quote(), &mentions, None).unwrap();
191 let entries: Value =
192 serde_json::from_str(properties["mentions"].as_str().unwrap()).unwrap();
193 assert_eq!(entries[0]["mri"], "19:c@thread.tacv2");
194 assert_eq!(entries[0]["mentionType"], "channel");
195 assert_eq!(entries[0]["itemid"], "1");
196 }
197
198 #[test]
199 fn a_team_mention_has_no_chatsvc_shape() {
200 let mentions = [mention(
201 0,
202 186 MentionTarget::Team {
203 187 team_id: "team-1".into(),
204 188 },
205 )];
206 assert!(quote_reply_properties(&quote(), &mentions, None).is_none());
189 ] {
190 let mentions = [mention(0, target)];
191 assert!(quote_reply_properties(&quote(), &mentions, None).is_none());
192 }
207 193 }
208 194
209 195 #[test]
@@ -66,16 +66,14 @@ pub(crate) fn quote_reply_properties(
66}
66}
67
67
68fn mention_entry(mention: &OutgoingMention) -> Option<Value> {
68fn mention_entry(mention: &OutgoingMention) -> Option<Value> {
69 let (mri, mention_type) = match &mention.target {
69 let MentionTarget::User { user_id } = &mention.target else {
70 MentionTarget::User { user_id } => (user_mri(user_id), "person"),
70 return None;
71 MentionTarget::Channel { channel_id } => (channel_id.clone(), "channel"),
72 MentionTarget::Team { .. } => return None,
73 };
71 };
74 Some(json!({
72 Some(json!({
75 "@type": MENTION_ITEMTYPE,
73 "@type": MENTION_ITEMTYPE,
76 "itemid": mention.id.to_string(),
74 "itemid": mention.id.to_string(),
77 "mri": mri,
75 "mri": user_mri(user_id),
78 "mentionType": mention_type,
76 "mentionType": "person",
79 "displayName": mention.text,
77 "displayName": mention.text,
80 }))
78 }))
81}
79}
@@ -180,30 +178,18 @@ mod tests {
180 }
178 }
181
179
182 #[test]
180 #[test]
183 fn a_channel_mention_points_at_the_channel_thread() {
181 fn channel_and_team_mentions_have_no_chatsvc_shape() {
184 let mentions = [mention(
182 for target in [
185 1,
186 MentionTarget::Channel {
183 MentionTarget::Channel {
187 channel_id: "19:c@thread.tacv2".into(),
184 channel_id: "19:c@thread.tacv2".into(),
188 },
185 },
189 )];
190 let properties = quote_reply_properties(&quote(), &mentions, None).unwrap();
191 let entries: Value =
192 serde_json::from_str(properties["mentions"].as_str().unwrap()).unwrap();
193 assert_eq!(entries[0]["mri"], "19:c@thread.tacv2");
194 assert_eq!(entries[0]["mentionType"], "channel");
195 assert_eq!(entries[0]["itemid"], "1");
196 }
197
198 #[test]
199 fn a_team_mention_has_no_chatsvc_shape() {
200 let mentions = [mention(
201 0,
202 MentionTarget::Team {
186 MentionTarget::Team {
203 team_id: "team-1".into(),
187 team_id: "team-1".into(),
204 },
188 },
205 )];
189 ] {
206 assert!(quote_reply_properties(&quote(), &mentions, None).is_none());
190 let mentions = [mention(0, target)];
191 assert!(quote_reply_properties(&quote(), &mentions, None).is_none());
192 }
207 }
193 }
208
194
209 #[test]
195 #[test]