aboutsummaryrefslogtreecommitdiffstats
path: root/filamento/src/chat.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--filamento/src/chat.rs36
1 files changed, 31 insertions, 5 deletions
diff --git a/filamento/src/chat.rs b/filamento/src/chat.rs
index c02654f..07577fd 100644
--- a/filamento/src/chat.rs
+++ b/filamento/src/chat.rs
@@ -13,17 +13,43 @@ use uuid::Uuid;
#[cfg_attr(feature = "reactive_stores", derive(reactive_stores::Store))]
pub struct Message {
pub id: Uuid,
- // does not contain full user information
- // bare jid (for now)
+ /// jid of user currently tied to the original sender, updated by jid move event. original sender can be found within the source data.
pub from: BareJID,
pub delivery: Option<Delivery>,
pub timestamp: DateTime<Utc>,
- // TODO: originally_from
- // TODO: message edits
- // TODO: message timestamp
+ // TODO: message edits. message edits will need to include the edit and the source stanza that caused the edit.
+ /// original message sources (XMPP, imported, etc.). cannot change, but may be deleted or have information redacted. can be multiple because a message may be updated, have reactions appended to it, delivery receipt, user moved, etc.
+ pub source: Vec<Source>,
pub body: Body,
}
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum Source {
+ XMPP(XMPPMessage),
+ // TODO: imported information
+ Imported,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct XMPPMessage {
+ // TODO: upon software updates, upgrade all message and xmppmessage structs with missed data from old XMPP raw messages. maybe just don't store parsed message in xmpp message, have it be a method
+ /// the raw data received from the xml stream
+ pub raw: String,
+ /// the timestamp the client received the stanza, or associated with the <delay> in the envelope.
+ pub timestamp: DateTime<Utc>,
+ /// if message was received in a carbon envolope, forwarded, or in an encrypted envelope, etc., the full xmpp message it came from is included here, linked. there could technically be multiple envelopes (same stanza received through multiple envelopes).
+ pub envelopes: Vec<XMPPMessage>,
+}
+
+impl XMPPMessage {
+ // TODO: syncify
+ // pub async fn parsed(&self) -> stanza::client::message::Message {
+ // let reader = peanuts::Reader::new(peanuts::ReadableString(self.raw.to_string()));
+ // let message = reader.read().await?;
+ // message
+ // }
+}
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum Delivery {