Skip to content

Commit 686f023

Browse files
added keep message type
1 parent 0164eea commit 686f023

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/imessage/aps_client.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,14 @@ impl IMClient {
213213
let command = payload.command;
214214
// delivered/read
215215
if let IDSRecvMessage {
216-
command: 101 | 102 | 113,
216+
command: 101 | 102 | 113 | 106,
217217
..
218218
} = &payload {
219219
return Ok(payload.to_message(None, match command {
220220
101 => Message::Delivered,
221221
102 => Message::Read,
222222
113 => Message::NotifyAnyways,
223+
106 => Message::Keep,
223224
_ => panic!("no")
224225
}).ok())
225226
}

src/imessage/messages.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,7 @@ pub enum Message {
16241624
ShareProfile(ShareProfileMessage),
16251625
NotifyAnyways,
16261626
SetTranscriptBackground(SetTranscriptBackgroundMessage),
1627+
Keep,
16271628
}
16281629

16291630

@@ -1678,6 +1679,7 @@ impl Message {
16781679
Self::ShareProfile(_) => 131,
16791680
Self::NotifyAnyways => 113,
16801681
Self::SetTranscriptBackground(_) => 138,
1682+
Self::Keep => 106,
16811683
}
16821684
}
16831685

@@ -1752,6 +1754,7 @@ impl Message {
17521754
Self::UpdateProfileSharing(_) => Some(true),
17531755
Self::NotifyAnyways => Some(true),
17541756
Self::SetTranscriptBackground(_) => Some(true),
1757+
Self::Keep => Some(true),
17551758
_ => None
17561759
}
17571760
}
@@ -1837,7 +1840,10 @@ impl fmt::Display for Message {
18371840
},
18381841
Message::SetTranscriptBackground(_) => {
18391842
write!(f, "Changed the transcript background")
1840-
}
1843+
},
1844+
Message::Keep => {
1845+
write!(f, "kept a message")
1846+
},
18411847
}
18421848
}
18431849
}
@@ -1943,6 +1949,7 @@ impl MessageInst {
19431949
Message::PeerCacheInvalidate => false,
19441950
Message::Unschedule => false,
19451951
Message::NotifyAnyways => false,
1952+
Message::Keep => false,
19461953
_ => true
19471954
}
19481955
}
@@ -2379,6 +2386,7 @@ impl MessageInst {
23792386
},
23802387
Message::Delivered => panic!("no enc body!"),
23812388
Message::Read => panic!("no enc body!"),
2389+
Message::Keep => panic!("no enc body!"),
23822390
Message::MessageReadOnDevice => panic!("no enc body!"),
23832391
Message::PeerCacheInvalidate => panic!("no enc body!"),
23842392
Message::Error(_) => panic!("no enc body!"),

src/test.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,16 @@ async fn main() {
501501
client.identity.certify_delivery("com.apple.madrid", &context, false).await.unwrap();
502502
}
503503
}
504+
//automatically keep audio messages
505+
if let Message::Message(normal_message) = &msg.message {
506+
if normal_message.voice {
507+
if let Some(conversation_data) = msg.conversation.clone() {
508+
let mut keep_msg = MessageInst::new(conversation_data, &handle, Message::Keep);
509+
keep_msg.id = msg.id.clone();
510+
client.send(&mut keep_msg).await.unwrap();
511+
}
512+
}
513+
}
504514
}
505515
},
506516
input = &mut read_task => {

0 commit comments

Comments
 (0)