Skip to content

Commit

Permalink
Merge pull request #409 from ReagentX/feat/cs/satellite-message-support
Browse files Browse the repository at this point in the history
Feat/cs/satellite message support
  • Loading branch information
ReagentX authored Dec 17, 2024
2 parents e1c7fa5 + 0b9e5fb commit a74f625
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 24 deletions.
10 changes: 1 addition & 9 deletions imessage-database/src/tables/messages/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 33 additions & 1 deletion imessage-database/src/tables/messages/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion imessage-exporter/src/exporters/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl<'a> Writer<'a> for HTML<'a> {
if message.is_from_me() {
self.add_line(
&mut formatted_message,
&format!("<div class=\"sent {:?}\">", message.service()),
&format!("<div class=\"sent {}\">", message.service()),
"",
"",
);
Expand Down
24 changes: 11 additions & 13 deletions imessage-exporter/src/exporters/resources/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a74f625

Please sign in to comment.