Fixes #2: Include own beta badge in payload object

This commit is contained in:
Paul
2021-08-06 17:34:48 +01:00
parent f09fde616a
commit 8890e3bab0
4 changed files with 16 additions and 9 deletions

View File

@@ -1,3 +1,3 @@
#!/bin/bash
export version=0.5.1-alpha.21
export version=0.5.1-alpha.22
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs

View File

@@ -119,8 +119,8 @@ impl User {
self
}
/// Mutate the user object to appear as seen by user.
pub fn with(mut self, permissions: UserPermissions<[u32; 1]>) -> User {
/// Apply any relevant badges.
pub fn apply_badges(mut self) -> User {
let mut badges = self.badges.unwrap_or_else(|| 0);
if let Ok(id) = Ulid::from_string(&self.id) {
if id.datetime().timestamp_millis() < *EARLY_ADOPTER_BADGE {
@@ -129,15 +129,21 @@ impl User {
}
self.badges = Some(badges);
self
}
/// Mutate the user object to appear as seen by user.
pub fn with(self, permissions: UserPermissions<[u32; 1]>) -> User {
let mut user = self.apply_badges();
if permissions.get_view_profile() {
self.online = Some(is_online(&self.id));
user.online = Some(is_online(&user.id));
} else {
self.status = None;
user.status = None;
}
self.profile = None;
self
user.profile = None;
user
}
/// Mutate the user object to appear as seen by user.

View File

@@ -112,7 +112,8 @@ pub async fn generate_ready(mut user: User) -> Result<ClientboundNotification> {
user.relationship = Some(RelationshipStatus::User);
user.online = Some(true);
users.push(user);
users.push(user.apply_badges());
Ok(ClientboundNotification::Ready {
users,

View File

@@ -1 +1 @@
pub const VERSION: &str = "0.5.1-alpha.21";
pub const VERSION: &str = "0.5.1-alpha.22";