Skip to content

Commit

Permalink
feat: sort past members by the timestamp of removal
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Feb 15, 2025
1 parent 96704eb commit 3c29f69
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3493,6 +3493,8 @@ pub async fn get_chat_contacts(context: &Context, chat_id: ChatId) -> Result<Vec
}

/// Returns a vector of contact IDs for given chat ID that are no longer part of the group.
///
/// Members that have been removed recently are in the beginning of the list.
pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Result<Vec<ContactId>> {
let now = time();
let list = context
Expand All @@ -3505,7 +3507,7 @@ pub async fn get_past_chat_contacts(context: &Context, chat_id: ChatId) -> Resul
WHERE cc.chat_id=?
AND cc.add_timestamp < cc.remove_timestamp
AND ? < cc.remove_timestamp
ORDER BY c.id=1, c.last_seen DESC, c.id DESC",
ORDER BY c.id=1, cc.remove_timestamp DESC, c.id DESC",
(chat_id, now.saturating_sub(60 * 24 * 3600)),
|row| row.get::<_, ContactId>(0),
|ids| ids.collect::<Result<Vec<_>, _>>().map_err(Into::into),
Expand Down

0 comments on commit 3c29f69

Please sign in to comment.