Skip to content

Commit

Permalink
fix: on DDC the user field in Relationship is not send in READY anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
kozabrada123 committed Nov 3, 2024
1 parent cd2f21e commit c97afa0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/types/entities/relationship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde_repr::{Deserialize_repr, Serialize_repr};
use crate::errors::ChorusError;
use crate::types::{Shared, Snowflake};

use super::{arc_rwlock_ptr_eq, PublicUser};
use super::{option_arc_rwlock_ptr_eq, PublicUser};

#[derive(Debug, Deserialize, Serialize, Clone, Default)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
Expand All @@ -25,7 +25,11 @@ pub struct Relationship {
pub nickname: Option<String>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] // Can be derived from the user id
/// The target user
pub user: Shared<PublicUser>,
///
/// Note: on Discord.com, this is not sent in select places, such as READY payload.
///
/// In such a case, you should refer to the id field and seperately fetch the user's data
pub user: Option<Shared<PublicUser>>,
/// When the user requested a relationship
pub since: Option<DateTime<Utc>>,
}
Expand All @@ -36,7 +40,7 @@ impl PartialEq for Relationship {
self.id == other.id
&& self.relationship_type == other.relationship_type
&& self.nickname == other.nickname
&& arc_rwlock_ptr_eq(&self.user, &other.user)
&& option_arc_rwlock_ptr_eq(&self.user, &other.user)
&& self.since == other.since
}
}
Expand Down

0 comments on commit c97afa0

Please sign in to comment.