fix: add back missing early adopter badge
This commit is contained in:
@@ -3,11 +3,12 @@ use std::{collections::HashSet, str::FromStr, time::Duration};
|
||||
use crate::{events::client::EventV1, Database, File, RatelimitEvent, AMQP};
|
||||
|
||||
use authifier::config::{EmailVerificationConfig, Template};
|
||||
use futures::future::join_all;
|
||||
use iso8601_timestamp::Timestamp;
|
||||
use once_cell::sync::Lazy;
|
||||
use rand::seq::SliceRandom;
|
||||
use revolt_config::{config, FeaturesLimits};
|
||||
use revolt_models::v0::{self, UserFlags};
|
||||
use revolt_models::v0::{self, UserFlags, UserBadges};
|
||||
use revolt_presence::filter_online;
|
||||
use revolt_result::{create_error, Result};
|
||||
use serde_json::json;
|
||||
@@ -348,15 +349,16 @@ impl User {
|
||||
) -> Result<Vec<v0::User>> {
|
||||
let online_ids = filter_online(ids).await;
|
||||
|
||||
Ok(db
|
||||
Ok(join_all(
|
||||
db
|
||||
.fetch_users(ids)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|user| {
|
||||
.map(|user| async {
|
||||
let is_online = online_ids.contains(&user.id);
|
||||
user.into_known(perspective, is_online)
|
||||
user.into_known(perspective, is_online).await
|
||||
})
|
||||
.collect())
|
||||
).await)
|
||||
}
|
||||
|
||||
/// Find a free discriminator for a given username
|
||||
@@ -807,4 +809,18 @@ impl User {
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Gets the user's badges along with calculating any dynamic badges
|
||||
pub async fn get_badges(&self) -> u32 {
|
||||
let config = config().await;
|
||||
let badges = self.badges.unwrap_or_default() as u32;
|
||||
|
||||
if let Some(cutoff) = config.api.users.early_adopter_cutoff {
|
||||
if Ulid::from_string(&self.id).unwrap().timestamp_ms() < cutoff {
|
||||
return badges + UserBadges::EarlyAdopter as u32
|
||||
};
|
||||
};
|
||||
|
||||
badges
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user