From 29e022ddb9c19b2e8de2ece7cbcdba9ed811e237 Mon Sep 17 00:00:00 2001 From: Christopher Sardegna Date: Mon, 16 Dec 2024 16:01:39 -0800 Subject: [PATCH 1/2] Support Satellite Messages for #404 --- .../src/tables/messages/message.rs | 10 +----- .../src/tables/messages/models.rs | 34 ++++++++++++++++++- imessage-exporter/src/exporters/html.rs | 2 +- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/imessage-database/src/tables/messages/message.rs b/imessage-database/src/tables/messages/message.rs index c95a9ab5..cbe1ff81 100644 --- a/imessage-database/src/tables/messages/message.rs +++ b/imessage-database/src/tables/messages/message.rs @@ -983,15 +983,7 @@ impl Message { /// Determine the service the message was sent from, i.e. iMessage, SMS, IRC, etc. pub fn service(&self) -> Service { - if let Some(service_name) = self.service.as_deref() { - return match service_name.trim() { - "iMessage" => Service::iMessage, - "SMS" => Service::SMS, - "rcs" | "RCS" => Service::RCS, - service_name => Service::Other(service_name), - }; - } - Service::Unknown + Service::from(self.service.as_deref()) } /// Extract a blob of data that belongs to a single message from a given column diff --git a/imessage-database/src/tables/messages/models.rs b/imessage-database/src/tables/messages/models.rs index de60e364..4a071770 100644 --- a/imessage-database/src/tables/messages/models.rs +++ b/imessage-database/src/tables/messages/models.rs @@ -2,6 +2,8 @@ This module contains Data structures and models that represent message data. */ +use std::fmt::{Display, Formatter, Result}; + use crate::{message_types::text_effects::TextEffect, util::typedstream::models::Archivable}; /// Defines the parts of a message bubble, i.e. the content that can exist in a single message. @@ -23,7 +25,7 @@ pub enum BubbleComponent<'a> { Retracted, } -/// Defines different types of services we can receive messages from. +/// Defines different types of [services](https://support.apple.com/en-us/104972) we can receive messages from. #[derive(Debug)] pub enum Service<'a> { /// An iMessage @@ -33,12 +35,42 @@ pub enum Service<'a> { SMS, /// A message sent as RCS RCS, + /// A message sent via [satellite](https://support.apple.com/en-us/120930) + Satellite, /// Any other type of message Other(&'a str), /// Used when service field is not set Unknown, } +impl<'a> Service<'a> { + pub fn from(service: Option<&'a str>) -> Self { + if let Some(service_name) = service { + return match service_name.trim() { + "iMessage" => Service::iMessage, + "iMessageLite" => Service::Satellite, + "SMS" => Service::SMS, + "rcs" | "RCS" => Service::RCS, + service_name => Service::Other(service_name), + }; + } + Service::Unknown + } +} + +impl<'a> Display for Service<'a> { + fn fmt(&self, fmt: &mut Formatter<'_>) -> Result { + match self { + Service::iMessage => write!(fmt, "iMessage"), + Service::SMS => write!(fmt, "SMS"), + Service::RCS => write!(fmt, "RCS"), + Service::Satellite => write!(fmt, "Satellite"), + Service::Other(other) => write!(fmt, "{other}"), + Service::Unknown => write!(fmt, "Unknown"), + } + } +} + /// Defines ranges of text and associated attributes parsed from [`typedstream`](crate::util::typedstream) `attributedBody` data. /// /// Ranges specify locations attributes applied to specific portions of a [`Message`](crate::tables::messages::Message)'s [`text`](crate::tables::messages::Message::text). For example, given message text with a [`Mention`](TextEffect::Mention) like: diff --git a/imessage-exporter/src/exporters/html.rs b/imessage-exporter/src/exporters/html.rs index f6630f3e..80d7421f 100644 --- a/imessage-exporter/src/exporters/html.rs +++ b/imessage-exporter/src/exporters/html.rs @@ -212,7 +212,7 @@ impl<'a> Writer<'a> for HTML<'a> { if message.is_from_me() { self.add_line( &mut formatted_message, - &format!("
", message.service()), + &format!("
", message.service()), "", "", ); From 0b9e5fbfcece6eafc0feb925795810868b59ee48 Mon Sep 17 00:00:00 2001 From: Christopher Sardegna Date: Mon, 16 Dec 2024 16:01:59 -0800 Subject: [PATCH 2/2] Improve CSS for #404 --- .../src/exporters/resources/style.css | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/imessage-exporter/src/exporters/resources/style.css b/imessage-exporter/src/exporters/resources/style.css index 18a6033c..7224d516 100644 --- a/imessage-exporter/src/exporters/resources/style.css +++ b/imessage-exporter/src/exporters/resources/style.css @@ -28,37 +28,35 @@ a[href^="#"] { overflow-wrap: break-word; } -.message .sent.iMessage { - background-color: #1982FC; +.message .sent, +.message .received { + border-radius: 25px; + padding: 15px; + max-width: 60%; + width: fit-content; } -.message .sent.sms { +.message .sent { background-color: #65c466 } -.message .sent.rcs { - background-color: #65c466 + +.message .sent.iMessage, +.message .sent.Satellite { + background-color: #1982FC; } .message .sent { color: white; - border-radius: 25px; - padding: 15px; margin-left: auto; margin-right: 0; - max-width: 60%; - width: fit-content; } .message .received { background-color: #d8d8d8; color: black; - border-radius: 25px; - padding: 15px; margin-right: auto; margin-left: 0; - max-width: 60%; - width: fit-content; } .message .sent .replies .reply .message .sent {