Skip to content

Commit

Permalink
update the query
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Dec 19, 2024
1 parent d4d3d30 commit 037b8de
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions xmtp_mls/src/storage/encrypted_store/group_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use serde::{Deserialize, Serialize};

use super::{
db_connection::DbConnection,
schema::group_messages::{self, dsl},
schema::{
group_messages::{self, dsl},
groups::dsl as groups_dsl,
},
Sqlite,
};
use crate::{impl_fetch, impl_store, impl_store_or_ignore, StorageError};
Expand Down Expand Up @@ -132,7 +135,20 @@ impl DbConnection {
args: &MsgQueryArgs,
) -> Result<Vec<StoredGroupMessage>, StorageError> {
let mut query = dsl::group_messages
.filter(dsl::group_id.eq(group_id))
.filter(
dsl::group_id.eq_any(
groups_dsl::groups
.filter(
groups_dsl::id.eq(group_id).or(groups_dsl::dm_id.eq_any(
groups_dsl::groups
.select(groups_dsl::dm_id)
.filter(groups_dsl::id.eq(group_id))
.into_boxed(),
)),
)
.select(groups_dsl::id),
),
)
.into_boxed();

if let Some(sent_after) = args.sent_after_ns {
Expand Down

0 comments on commit 037b8de

Please sign in to comment.