mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 20:26:52 +00:00
fix: Address redacted content review nitpicks
This commit is contained in:
1 parent
f154ecb542
commit
8603ae21cc
3 files changed
+24
-19
No files matched your search
@@ -95,18 +95,18 @@ pub(crate) async fn get_room_event_route(
|
||||
}
|
||||
|
||||
async fn unredact(services: &crate::State, sender_user: &UserId, event: &mut PduEvent) -> Result {
|
||||
let power_levels = services
|
||||
.rooms
|
||||
.state_accessor
|
||||
.get_room_power_levels(&event.room_id_or_hash())
|
||||
.await;
|
||||
if !services.users.is_admin(sender_user).await {
|
||||
let power_levels = services
|
||||
.rooms
|
||||
.state_accessor
|
||||
.get_room_power_levels(&event.room_id_or_hash())
|
||||
.await;
|
||||
|
||||
if power_levels.for_user(sender_user) < power_levels.redact
|
||||
&& !services.users.is_admin(sender_user).await
|
||||
{
|
||||
return Err!(Request(Forbidden(
|
||||
"You don't have permission to view redacted content in this room."
|
||||
)));
|
||||
if power_levels.for_user(sender_user) < power_levels.redact {
|
||||
return Err!(Request(Forbidden(
|
||||
"You don't have permission to view redacted content in this room."
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
let content = services
|
||||
|
||||
@@ -93,7 +93,7 @@ struct Services {
|
||||
users: Dep<users::Service>,
|
||||
}
|
||||
|
||||
const PURGE_INTERVAL_SECS: u64 = 60 * 60;
|
||||
const PURGE_INTERVAL_SECS: u64 = 3600;
|
||||
|
||||
type RoomMutexMap = MutexMap<OwnedRoomId, ()>;
|
||||
pub type RoomMutexGuard = MutexMapGuard<OwnedRoomId, ()>;
|
||||
|
||||
@@ -4,7 +4,7 @@ use conduwuit_core::{
|
||||
utils::{self},
|
||||
warn,
|
||||
};
|
||||
use ruma::{EventId, events::room::encrypted::Relation};
|
||||
use ruma::{EventId, events::room::encrypted::Relation, signatures::content_hash};
|
||||
|
||||
use super::{ExtractBody, ExtractRelatesTo};
|
||||
use crate::rooms::short::ShortRoomId;
|
||||
@@ -52,13 +52,18 @@ impl super::Service {
|
||||
.get_room_version(&pdu.room_id_or_hash())
|
||||
.await?;
|
||||
|
||||
if !pdu.is_redacted()
|
||||
&& self
|
||||
.services
|
||||
.config
|
||||
.allow_moderators_to_view_redacted_content
|
||||
if self
|
||||
.services
|
||||
.config
|
||||
.allow_moderators_to_view_redacted_content
|
||||
{
|
||||
self.db.save_unredacted_content(&pdu_id, &pdu.content);
|
||||
let mut pdu_json = self.get_pdu_json_from_id(&pdu_id).await?;
|
||||
pdu_json.remove("event_id");
|
||||
if content_hash(&pdu_json)
|
||||
.is_ok_and(|hash| hash.encode() == pdu.hashes.sha256.trim_end_matches('='))
|
||||
{
|
||||
self.db.save_unredacted_content(&pdu_id, &pdu.content);
|
||||
}
|
||||
}
|
||||
|
||||
pdu.redact(&room_version_id, Some(reason.event_id()))?;
|
||||
|
||||
Reference in new issue
Block a user