Skip to content

Commit

Permalink
fix: Don't treat location-only and sync messages as bot ones (#6357)
Browse files Browse the repository at this point in the history
  • Loading branch information
iequidoo committed Jan 2, 2025
1 parent 25933b1 commit 1792d48
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@ Content-Disposition: attachment; filename="location.kml"
assert_eq!(get_range(alice, None, None, 0, 0).await?.len(), 1);
assert_eq!(get_range(bob, None, None, 0, 0).await?.len(), 1);

// Location-only messages are "auto-generated", but they mustn't make the contact a bot.
let contact = bob.add_or_lookup_contact(alice).await;
assert!(!contact.is_bot());

// Day later Bob removes location.
SystemTime::shift(Duration::from_secs(86400));
delete_expired(alice, time()).await?;
Expand Down
7 changes: 6 additions & 1 deletion src/mimeparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,12 @@ impl MimeMessage {
},
};

if parser.mdn_reports.is_empty() && parser.webxdc_status_update.is_none() {
let is_location_only = parser.location_kml.is_some() && parser.parts.is_empty();
if parser.mdn_reports.is_empty()
&& !is_location_only
&& parser.sync_items.is_none()
&& parser.webxdc_status_update.is_none()
{
let is_bot =
parser.headers.get("auto-submitted") == Some(&"auto-generated".to_string());
parser.is_bot = Some(is_bot);
Expand Down
4 changes: 4 additions & 0 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ mod tests {
assert!(token::exists(&alice2, token::Namespace::Auth, "testtoken").await?);
assert_eq!(Chatlist::try_load(&alice2, 0, None, None).await?.len(), 0);

// Sync messages are "auto-generated", but they mustn't make the self-contact a bot.
let self_contact = alice2.add_or_lookup_contact(&alice2).await;
assert!(!self_contact.is_bot());

// the same sync message sent to bob must not be executed
let bob = TestContext::new_bob().await;
bob.recv_msg(&sent_msg).await;
Expand Down

0 comments on commit 1792d48

Please sign in to comment.