BlueGit

ict rusty-teams

fix(channels): no empty Unknown posts for member events

- member added, left and removed events stay out of the channel feed, like Teams
- blank system posts without sender and content too

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-09 · 3 weeks ago

Hash
a528c980a4993ab184891791a40b7d1f1b8be935
Parent
9e1f3972
1 file changed +25 −0
crates/app-state/src/rows.rs +25 −0
@@ -1087,6 +1087,9 @@ fn post_row(
1087 1087 /// Channel feed: Teams shows a Meet now meeting as its own post and keeps the other call notices
1088 1088 /// inside the thread; a saved recording stays visible as a reply.
1089 1089 fn shows_in_feed(record: &MessageRecord, event: Option<&CallEvent>) -> bool {
1090 if roster_event(record).is_some() || is_blank_system_record(record) {
1091 return false;
1092 }
1090 1093 match event {
1091 1094 None => true,
1092 1095 Some(event) if record.reply_to_id.is_none() => event.phase == CallPhase::Started,
@@ -1094,6 +1097,14 @@ fn shows_in_feed(record: &MessageRecord, event: Option<&CallEvent>) -> bool {
1094 1097 }
1095 1098 }
1096 1099
1100 fn is_blank_system_record(record: &MessageRecord) -> bool {
1101 record.sender_id.is_none()
1102 && record.call_event_json.is_none()
1103 && record.body_html.trim().is_empty()
1104 && record.subject.as_deref().is_none_or(|subject| subject.trim().is_empty())
1105 && record.attachments_json.trim() == "[]"
1106 }
1107
1097 1108 pub fn thread_list_rows(
1098 1109 records: &[MessageRecord],
1099 1110 context: &RowContext,
@@ -1636,6 +1647,20 @@ mod tests {
1636 1647 assert_eq!(keys(&rows), vec!["r1", "r3", "r2"]);
1637 1648 }
1638 1649
1650 #[test]
1651 fn member_events_and_blank_system_posts_stay_out_of_the_channel_feed() {
1652 let mut joined = record("j1", None, 9, 6);
1653 joined.sender_id = None;
1654 joined.body_html = String::new();
1655 joined.call_event_json = Some(r#"{"roster":{"change":"Added","initiator_id":"a","initiator_name":null,"member_ids":["b"],"member_names":[null],"history":"All","topic":null}}"#.into());
1656 let mut blank = record("b1", None, 10, 6);
1657 blank.sender_id = None;
1658 blank.body_html = String::new();
1659 let records = vec![record("r1", None, 8, 6), joined, blank];
1660 let rows = thread_list_rows(&records, &context(), false);
1661 assert_eq!(keys(&rows), vec!["r1"]);
1662 }
1663
1639 1664 #[test]
1640 1665 fn feed_puts_load_older_at_the_bottom() {
1641 1666 let records = vec![record("r1", None, 8, 6), record("r2", None, 9, 6)];
@@ -1087,6 +1087,9 @@ fn post_row(
1087/// Channel feed: Teams shows a Meet now meeting as its own post and keeps the other call notices
1087/// Channel feed: Teams shows a Meet now meeting as its own post and keeps the other call notices
1088/// inside the thread; a saved recording stays visible as a reply.
1088/// inside the thread; a saved recording stays visible as a reply.
1089fn shows_in_feed(record: &MessageRecord, event: Option<&CallEvent>) -> bool {
1089fn shows_in_feed(record: &MessageRecord, event: Option<&CallEvent>) -> bool {
1090 if roster_event(record).is_some() || is_blank_system_record(record) {
1091 return false;
1092 }
1090 match event {
1093 match event {
1091 None => true,
1094 None => true,
1092 Some(event) if record.reply_to_id.is_none() => event.phase == CallPhase::Started,
1095 Some(event) if record.reply_to_id.is_none() => event.phase == CallPhase::Started,
@@ -1094,6 +1097,14 @@ fn shows_in_feed(record: &MessageRecord, event: Option<&CallEvent>) -> bool {
1094 }
1097 }
1095}
1098}
1096
1099
1100fn is_blank_system_record(record: &MessageRecord) -> bool {
1101 record.sender_id.is_none()
1102 && record.call_event_json.is_none()
1103 && record.body_html.trim().is_empty()
1104 && record.subject.as_deref().is_none_or(|subject| subject.trim().is_empty())
1105 && record.attachments_json.trim() == "[]"
1106}
1107
1097pub fn thread_list_rows(
1108pub fn thread_list_rows(
1098 records: &[MessageRecord],
1109 records: &[MessageRecord],
1099 context: &RowContext,
1110 context: &RowContext,
@@ -1636,6 +1647,20 @@ mod tests {
1636 assert_eq!(keys(&rows), vec!["r1", "r3", "r2"]);
1647 assert_eq!(keys(&rows), vec!["r1", "r3", "r2"]);
1637 }
1648 }
1638
1649
1650 #[test]
1651 fn member_events_and_blank_system_posts_stay_out_of_the_channel_feed() {
1652 let mut joined = record("j1", None, 9, 6);
1653 joined.sender_id = None;
1654 joined.body_html = String::new();
1655 joined.call_event_json = Some(r#"{"roster":{"change":"Added","initiator_id":"a","initiator_name":null,"member_ids":["b"],"member_names":[null],"history":"All","topic":null}}"#.into());
1656 let mut blank = record("b1", None, 10, 6);
1657 blank.sender_id = None;
1658 blank.body_html = String::new();
1659 let records = vec![record("r1", None, 8, 6), joined, blank];
1660 let rows = thread_list_rows(&records, &context(), false);
1661 assert_eq!(keys(&rows), vec!["r1"]);
1662 }
1663
1639 #[test]
1664 #[test]
1640 fn feed_puts_load_older_at_the_bottom() {
1665 fn feed_puts_load_older_at_the_bottom() {
1641 let records = vec![record("r1", None, 8, 6), record("r2", None, 9, 6)];
1666 let records = vec![record("r1", None, 8, 6), record("r2", None, 9, 6)];