Fix deletion of private notes (#814)

This commit is contained in:
Geometrically
2023-12-28 20:25:55 -05:00
committed by GitHub
parent f199ecf8e9
commit cf9c8cbb4f
4 changed files with 26 additions and 6 deletions

View File

@@ -40,7 +40,10 @@ pub enum LegacyMessageBody {
},
ThreadClosure,
ThreadReopen,
Deleted,
Deleted {
#[serde(default)]
private: bool,
},
}
#[derive(Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
@@ -90,7 +93,9 @@ impl From<crate::models::v3::threads::MessageBody> for LegacyMessageBody {
crate::models::v3::threads::MessageBody::ThreadReopen => {
LegacyMessageBody::ThreadReopen
}
crate::models::v3::threads::MessageBody::Deleted => LegacyMessageBody::Deleted,
crate::models::v3::threads::MessageBody::Deleted { private } => {
LegacyMessageBody::Deleted { private }
}
}
}
}

View File

@@ -51,7 +51,10 @@ pub enum MessageBody {
},
ThreadClosure,
ThreadReopen,
Deleted,
Deleted {
#[serde(default)]
private: bool,
},
}
#[derive(Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
@@ -103,6 +106,8 @@ impl Thread {
.filter(|x| {
if let MessageBody::Text { private, .. } = x.body {
!private || user.role.is_mod()
} else if let MessageBody::Deleted { private, .. } = x.body {
!private || user.role.is_mod()
} else {
true
}