pub struct Message {
Show 25 fields pub rowid: i32, pub guid: String, pub text: Option<String>, pub service: Option<String>, pub handle_id: i32, pub subject: Option<String>, pub date: i64, pub date_read: i64, pub date_delivered: i64, pub is_from_me: bool, pub is_read: bool, pub item_type: i32, pub group_title: Option<String>, pub group_action_type: i32, pub associated_message_guid: Option<String>, pub associated_message_type: Option<i32>, pub balloon_bundle_id: Option<String>, pub expressive_send_style_id: Option<String>, pub thread_originator_guid: Option<String>, pub thread_originator_part: Option<String>, pub date_edited: i64, pub chat_id: Option<i32>, pub num_attachments: i32, pub deleted_from: Option<i32>, pub num_replies: i32,
}
Expand description

Represents a single row in the message table.

Fields§

§rowid: i32§guid: String§text: Option<String>§service: Option<String>§handle_id: i32§subject: Option<String>§date: i64§date_read: i64§date_delivered: i64§is_from_me: bool§is_read: bool§item_type: i32§group_title: Option<String>§group_action_type: i32§associated_message_guid: Option<String>§associated_message_type: Option<i32>§balloon_bundle_id: Option<String>§expressive_send_style_id: Option<String>§thread_originator_guid: Option<String>§thread_originator_part: Option<String>§date_edited: i64§chat_id: Option<i32>§num_attachments: i32§deleted_from: Option<i32>§num_replies: i32

Implementations§

source§

impl Message

source

pub fn gen_text<'a>( &'a mut self, db: &'a Connection ) -> Result<&'a str, MessageError>

Get the body text of a message, parsing it as streamtyped data if necessary. TODO: resolve the compiler warnings with this method

source

pub fn body(&self) -> Vec<BubbleType<'_>>

Get a vector of a message’s components

If the message has attachments, there will be one U+FFFC character for each attachment and one U+FFFD for app messages that we need to format.

An iMessage that contains body text like:

\u{FFFC}Check out this photo!

Will have a body() of:

[BubbleType::Attachment, BubbleType::Text("Check out this photo!")]

source

pub fn get_local_time( &self, date_stamp: &i64, offset: &i64 ) -> Result<DateTime<Local>, MessageError>

Create a DateTime<Local> from an arbitrary date and offset

This is used to create date data for anywhere dates are stored in the table, including plist payload or streamtyped data. In this struct, the other date methods invoke this method.

source

pub fn date(&self, offset: &i64) -> Result<DateTime<Local>, MessageError>

Calculates the date a message was written to the database.

This field is stored as a unix timestamp with an epoch of 2001-01-01 00:00:00 in the local time zone

source

pub fn date_delivered( &self, offset: &i64 ) -> Result<DateTime<Local>, MessageError>

Calculates the date a message was marked as delivered.

This field is stored as a unix timestamp with an epoch of 2001-01-01 00:00:00 in the local time zone

source

pub fn date_read(&self, offset: &i64) -> Result<DateTime<Local>, MessageError>

Calculates the date a message was marked as read.

This field is stored as a unix timestamp with an epoch of 2001-01-01 00:00:00 in the local time zone

source

pub fn date_edited(&self, offset: &i64) -> Result<DateTime<Local>, MessageError>

Calculates the date a message was most recently edited.

This field is stored as a unix timestamp with an epoch of 2001-01-01 00:00:00 in the local time zone

source

pub fn time_until_read(&self, offset: &i64) -> Option<String>

Gets the time until the message was read. This can happen in two ways:

  • You received a message, then waited to read it
  • You sent a message, and the recipient waited to read it

In the former case, this subtracts the date read column (date_read) from the date received column (date). In the latter case, this subtracts the date delivered column (date_delivered) from the date received column (date).

Not all messages get tagged with the read properties. If more than one message has been sent in a thread before getting read, only the most recent message will get the tag.

source

pub fn is_reply(&self) -> bool

true if the message is a response to a thread, else false

source

pub fn is_announcement(&self) -> bool

true if the message renames a thread, else false

source

pub fn is_reaction(&self) -> bool

true if the message is a reaction to another message, else false

source

pub fn is_sticker(&self) -> bool

true if the message is sticker, else false

source

pub fn is_expressive(&self) -> bool

true if the message has an expressive presentation, else false

source

pub fn is_url(&self) -> bool

true if the message has a URL preview, else false

source

pub fn is_edited(&self) -> bool

true if the message was edited, else false

source

pub fn has_attachments(&self) -> bool

true if the message has attachments, else false

source

pub fn has_replies(&self) -> bool

true if the message begins a thread, else false

source

pub fn is_shareplay(&self) -> bool

true if the message is a SharePlay/FaceTime message, else false

source

pub fn is_deleted(&self) -> bool

true if the message was deleted and is recoverable, else false

source

pub fn get_count( db: &Connection, context: &QueryContext ) -> Result<u64, TableError>

Get the number of messages in the database

Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::{Diagnostic, get_connection};
use imessage_database::tables::messages::Message;
use imessage_database::util::query_context::QueryContext;

let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
let context = QueryContext::default();
Message::get_count(&conn, &context);
source

pub fn stream_rows<'a>( db: &'a Connection, context: &'a QueryContext ) -> Result<Statement<'a>, TableError>

Stream messages from the database with optional filters

Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::{Diagnostic, get_connection};
use imessage_database::tables::messages::Message;
use imessage_database::util::query_context::QueryContext;

let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
let context = QueryContext::default();
Message::stream_rows(&conn, &context).unwrap();
source

pub fn get_reactions( &self, db: &Connection, reactions: &HashMap<String, Vec<String>> ) -> Result<HashMap<usize, Vec<Self>>, TableError>

Build a HashMap of message component index to messages that react to that component

source

pub fn get_replies( &self, db: &Connection ) -> Result<HashMap<usize, Vec<Self>>, TableError>

Build a HashMap of message component index to messages that reply to that component

source

pub fn variant(&self) -> Variant<'_>

Get the variant of a message, see crate::message_types::variants for detail.

source

pub fn get_announcement(&self) -> Option<Announcement<'_>>

Determine the type of announcement a message contains, if it contains one

source

pub fn service(&self) -> Service<'_>

Determine the service the message was sent from, i.e. iMessage, SMS, IRC, etc.

source

pub fn payload_data(&self, db: &Connection) -> Option<Value>

Get a message’s plist from the payload_data BLOB column

Calling this hits the database, so it is expensive and should only get invoked when needed.

This column contains data used by iMessage app balloons.

source

pub fn message_summary_info(&self, db: &Connection) -> Option<Value>

Get a message’s plist from the message_summary_info BLOB column

Calling this hits the database, so it is expensive and should only get invoked when needed.

This column contains data used by edited iMessages.

source

pub fn attributed_body(&self, db: &Connection) -> Option<Vec<u8>>

Get a message’s plist from the attributedBody BLOB column

Calling this hits the database, so it is expensive and should only get invoked when needed.

This column contains the message’s body text with any other attributes.

source

pub fn get_expressive(&self) -> Expressive<'_>

Determine which expressive the message was sent with

Trait Implementations§

source§

impl Cacheable for Message

source§

fn cache(db: &Connection) -> Result<HashMap<Self::K, Self::V>, TableError>

Used for reactions that do not exist in a foreign key table

Builds a map like:

{ message_guid: { 0: [Message, Message], 1: Message } }

Where the 0 and 1 are the reaction indexes in the body of the message mapped by message_guid

§

type K = String

§

type V = HashMap<usize, Vec<Message, Global>, RandomState>

source§

impl Debug for Message

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Diagnostic for Message

source§

fn run_diagnostic(db: &Connection)

Emit diagnostic data for the Messages table

Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::{Diagnostic, get_connection};
use imessage_database::tables::messages::Message;

let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
Message::run_diagnostic(&conn);
source§

impl Table for Message

source§

fn from_row(row: &Row<'_>) -> Result<Message>

Serializes a single row of data to an instance of the struct that implements this Trait
source§

fn get(db: &Connection) -> Result<Statement<'_>, TableError>

Gets a statement we can execute to iterate over the data in the table
source§

fn extract( message: Result<Result<Self, Error>, Error> ) -> Result<Self, TableError>

Extract valid row data while handling both types of query errors

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.