mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
Merge branch 'master' of github.com:revoltchat/backend into webhooks
This commit is contained in:
@@ -395,7 +395,7 @@ impl BulkMessageResponse {
|
||||
) -> Result<BulkMessageResponse> {
|
||||
if let Some(true) = include_users {
|
||||
let user_ids = messages.get_user_ids();
|
||||
let users = db.fetch_users(&user_ids).await?;
|
||||
let users = User::fetch_foreign_users(db, &user_ids).await?;
|
||||
|
||||
Ok(match channel {
|
||||
Channel::TextChannel { server, .. } | Channel::VoiceChannel { server, .. } => {
|
||||
|
||||
@@ -4,6 +4,7 @@ use crate::models::user::{
|
||||
};
|
||||
use crate::permissions::defn::UserPerms;
|
||||
use crate::permissions::r#impl::user::get_relationship;
|
||||
use crate::presence::presence_filter_online;
|
||||
use crate::{perms, Database, Error, Result};
|
||||
|
||||
use futures::try_join;
|
||||
@@ -67,6 +68,7 @@ impl User {
|
||||
}
|
||||
|
||||
/// Mutate the user object to remove redundant information
|
||||
#[must_use]
|
||||
pub fn foreign(mut self) -> User {
|
||||
self.profile = None;
|
||||
self.relations = None;
|
||||
@@ -94,6 +96,21 @@ impl User {
|
||||
self
|
||||
}
|
||||
|
||||
/// Fetch foreign users by a list of IDs
|
||||
pub async fn fetch_foreign_users(db: &Database, user_ids: &[String]) -> Result<Vec<User>> {
|
||||
let online_ids = presence_filter_online(user_ids).await;
|
||||
|
||||
Ok(db
|
||||
.fetch_users(user_ids)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|mut user| {
|
||||
user.online = Some(online_ids.contains(&user.id));
|
||||
user.foreign()
|
||||
})
|
||||
.collect::<Vec<User>>())
|
||||
}
|
||||
|
||||
/// Mutate the user object to include relationship (if it does not already exist)
|
||||
#[must_use]
|
||||
pub fn with_relationship(self, perspective: &User) -> User {
|
||||
|
||||
Reference in New Issue
Block a user