Skip to content

Commit cfd66ae

Browse files
committed
add published_in_epoch to group message
1 parent 533cc84 commit cfd66ae

24 files changed

+958
-901
lines changed

bindings_wasm/src/conversation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ mod tests {
808808
originator_id: 0,
809809
sequence_id: 0,
810810
expire_at_ns: None,
811+
published_in_epoch: None,
811812
};
812813
crate::to_value(&stored_message).unwrap();
813814
}

xmtp_db/migrations/.diesel_lock

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- This file should undo anything in `up.sql`
2+
ALTER TABLE group_messages DROP COLUMN published_in_epoch;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Your SQL goes here
2+
ALTER TABLE group_messages ADD COLUMN published_in_epoch BIGINT;
3+

xmtp_db/src/encrypted_store/group_message.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ pub struct StoredGroupMessage {
7676
pub inserted_at_ns: i64,
7777
/// Timestamp (in NS) after which the message must be deleted
7878
pub expire_at_ns: Option<i64>,
79+
/// the epoch this message was published in
80+
pub published_in_epoch: Option<i64>,
7981
}
8082

8183
impl StoredGroupMessage {
@@ -108,6 +110,8 @@ struct NewStoredGroupMessage {
108110
pub sequence_id: i64,
109111
// inserted_at_ns is NOT included - let database set it
110112
pub expire_at_ns: Option<i64>,
113+
/// the epoch this message was published in
114+
pub published_in_epoch: Option<i64>,
111115
}
112116

113117
impl From<&StoredGroupMessage> for NewStoredGroupMessage {
@@ -129,6 +133,7 @@ impl From<&StoredGroupMessage> for NewStoredGroupMessage {
129133
originator_id: msg.originator_id,
130134
sequence_id: msg.sequence_id,
131135
expire_at_ns: msg.expire_at_ns,
136+
published_in_epoch: msg.published_in_epoch,
132137
}
133138
}
134139
}

xmtp_db/src/encrypted_store/group_message/convert.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ impl TryFrom<GroupMessageSave> for StoredGroupMessage {
3232
.unwrap_or(Originators::APPLICATION_MESSAGES.into()),
3333
expire_at_ns: None,
3434
inserted_at_ns: 0, // Will be set by database
35+
published_in_epoch: value.published_in_epoch,
3536
})
3637
}
3738
}
@@ -109,6 +110,7 @@ impl From<StoredGroupMessage> for GroupMessageSave {
109110
reference_id: value.reference_id,
110111
sequence_id: Some(value.sequence_id),
111112
originator_id: Some(value.originator_id),
113+
published_in_epoch: value.published_in_epoch,
112114
}
113115
}
114116
}

xmtp_db/src/encrypted_store/group_message/messages_newer_than_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fn generate_message_with_cursor(
3030
sequence_id,
3131
originator_id,
3232
expire_at_ns: None,
33+
published_in_epoch: None,
3334
}
3435
}
3536

xmtp_db/src/encrypted_store/group_message/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub(crate) fn generate_message(
3131
originator_id: 0,
3232
expire_at_ns,
3333
inserted_at_ns: 0, // Will be set by database
34+
published_in_epoch: None,
3435
}
3536
}
3637

@@ -608,6 +609,7 @@ pub(crate) fn generate_message_with_reference<C: ConnectionExt>(
608609
originator_id: 0,
609610
expire_at_ns: None,
610611
inserted_at_ns: 0, // Will be set by database
612+
published_in_epoch: None,
611613
};
612614
message.store(conn).unwrap();
613615
message

xmtp_db/src/encrypted_store/schema_gen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ diesel::table! {
6666
sequence_id -> BigInt,
6767
inserted_at_ns -> BigInt,
6868
expire_at_ns -> Nullable<BigInt>,
69+
published_in_epoch -> Nullable<BigInt>,
6970
}
7071
}
7172

xmtp_mls/src/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ where
797797
originator_id: conversation_item.originator_id?,
798798
expire_at_ns: None, //Question: do we need to include this in conversation last message?
799799
inserted_at_ns: 0, // Not used for conversation list display
800+
published_in_epoch: None
800801
});
801802
if msg.is_none() {
802803
tracing::warn!("tried listing message, but message had missing fields so it was skipped");

0 commit comments

Comments
 (0)