imessage_database/tables/messages/models/
group_action.rs1use crate::tables::messages::message::Message;
6
7#[derive(Debug, PartialEq, Eq)]
9pub enum GroupAction<'a> {
10 ParticipantAdded(i32),
12 ParticipantRemoved(i32),
14 NameChange(&'a str),
16 ParticipantLeft,
18 GroupIconChanged,
20 GroupIconRemoved,
22 ChatBackgroundChanged,
24 ChatBackgroundRemoved,
26 PhoneNumberChanged(i32),
28}
29
30impl<'a> GroupAction<'a> {
31 #[must_use]
33 pub(crate) fn from_message(message: &'a Message) -> Option<Self> {
34 match (
35 message.item_type,
36 message.group_action_type,
37 message.other_handle,
38 &message.group_title,
39 ) {
40 (1, 0, Some(who), _) if message.handle_id == Some(who) => {
42 Some(Self::PhoneNumberChanged(who))
43 }
44 (1, 0, Some(who), _) => Some(Self::ParticipantAdded(who)),
45 (1, 1, Some(who), _) => Some(Self::ParticipantRemoved(who)),
46 (2, _, _, Some(name)) => Some(Self::NameChange(name)),
47 (3, 0, _, _) => Some(Self::ParticipantLeft),
48 (3, 1, _, _) => Some(Self::GroupIconChanged),
49 (3, 2, _, _) => Some(Self::GroupIconRemoved),
50 (3, 4, _, _) => Some(Self::ChatBackgroundChanged),
51 (3, 6, _, _) => Some(Self::ChatBackgroundRemoved),
52 _ => None,
53 }
54 }
55}