mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-15 13:16:56 +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 {
|
async fn unredact(services: &crate::State, sender_user: &UserId, event: &mut PduEvent) -> Result {
|
||||||
let power_levels = services
|
if !services.users.is_admin(sender_user).await {
|
||||||
.rooms
|
let power_levels = services
|
||||||
.state_accessor
|
.rooms
|
||||||
.get_room_power_levels(&event.room_id_or_hash())
|
.state_accessor
|
||||||
.await;
|
.get_room_power_levels(&event.room_id_or_hash())
|
||||||
|
.await;
|
||||||
|
|
||||||
if power_levels.for_user(sender_user) < power_levels.redact
|
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."
|
||||||
return Err!(Request(Forbidden(
|
)));
|
||||||
"You don't have permission to view redacted content in this room."
|
}
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = services
|
let content = services
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ struct Services {
|
|||||||
users: Dep<users::Service>,
|
users: Dep<users::Service>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const PURGE_INTERVAL_SECS: u64 = 60 * 60;
|
const PURGE_INTERVAL_SECS: u64 = 3600;
|
||||||
|
|
||||||
type RoomMutexMap = MutexMap<OwnedRoomId, ()>;
|
type RoomMutexMap = MutexMap<OwnedRoomId, ()>;
|
||||||
pub type RoomMutexGuard = MutexMapGuard<OwnedRoomId, ()>;
|
pub type RoomMutexGuard = MutexMapGuard<OwnedRoomId, ()>;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use conduwuit_core::{
|
|||||||
utils::{self},
|
utils::{self},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use ruma::{EventId, events::room::encrypted::Relation};
|
use ruma::{EventId, events::room::encrypted::Relation, signatures::content_hash};
|
||||||
|
|
||||||
use super::{ExtractBody, ExtractRelatesTo};
|
use super::{ExtractBody, ExtractRelatesTo};
|
||||||
use crate::rooms::short::ShortRoomId;
|
use crate::rooms::short::ShortRoomId;
|
||||||
@@ -52,13 +52,18 @@ impl super::Service {
|
|||||||
.get_room_version(&pdu.room_id_or_hash())
|
.get_room_version(&pdu.room_id_or_hash())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if !pdu.is_redacted()
|
if self
|
||||||
&& self
|
.services
|
||||||
.services
|
.config
|
||||||
.config
|
.allow_moderators_to_view_redacted_content
|
||||||
.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()))?;
|
pdu.redact(&room_version_id, Some(reason.event_id()))?;
|
||||||
|
|||||||
Reference in new issue
Block a user