You've already forked AstralRinth
Fix issue with moderator identities being revealed (#892)
* Fix issue with moderator identities being revealed * Fix on multiple threads route * Fix thread notifs * Fix failing test * fix thread messages returning nothing
This commit is contained in:
@@ -30,8 +30,6 @@ pub enum LegacyMessageBody {
|
||||
body: String,
|
||||
#[serde(default)]
|
||||
private: bool,
|
||||
#[serde(default)]
|
||||
hide_identity: bool,
|
||||
replying_to: Option<ThreadMessageId>,
|
||||
#[serde(default)]
|
||||
associated_images: Vec<ImageId>,
|
||||
@@ -76,13 +74,11 @@ impl From<crate::models::v3::threads::MessageBody> for LegacyMessageBody {
|
||||
private,
|
||||
replying_to,
|
||||
associated_images,
|
||||
hide_identity,
|
||||
} => LegacyMessageBody::Text {
|
||||
body,
|
||||
private,
|
||||
replying_to,
|
||||
associated_images,
|
||||
hide_identity,
|
||||
},
|
||||
crate::models::v3::threads::MessageBody::StatusChange {
|
||||
new_status,
|
||||
|
||||
@@ -32,6 +32,7 @@ pub struct ThreadMessage {
|
||||
pub author_id: Option<UserId>,
|
||||
pub body: MessageBody,
|
||||
pub created: DateTime<Utc>,
|
||||
pub hide_identity: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
@@ -41,8 +42,6 @@ pub enum MessageBody {
|
||||
body: String,
|
||||
#[serde(default)]
|
||||
private: bool,
|
||||
#[serde(default)]
|
||||
hide_identity: bool,
|
||||
replying_to: Option<ThreadMessageId>,
|
||||
#[serde(default)]
|
||||
associated_images: Vec<ImageId>,
|
||||
@@ -116,24 +115,17 @@ impl Thread {
|
||||
})
|
||||
.map(|x| ThreadMessage {
|
||||
id: x.id.into(),
|
||||
author_id: if users
|
||||
.iter()
|
||||
.find(|y| x.author_id == Some(y.id.into()))
|
||||
.map(|x| x.role.is_mod() && !user.role.is_mod())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
author_id: if x.hide_identity && !user.role.is_mod() {
|
||||
None
|
||||
} else {
|
||||
x.author_id.map(|x| x.into())
|
||||
},
|
||||
body: x.body,
|
||||
created: x.created,
|
||||
hide_identity: x.hide_identity,
|
||||
})
|
||||
.collect(),
|
||||
members: users
|
||||
.into_iter()
|
||||
.filter(|x| !x.role.is_mod() || user.role.is_mod())
|
||||
.collect(),
|
||||
members: users,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user