mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Add admin command to reset user push rules
This commit is contained in:
@@ -3,7 +3,10 @@ use std::{
|
|||||||
fmt::Write as _,
|
fmt::Write as _,
|
||||||
};
|
};
|
||||||
|
|
||||||
use api::client::{full_user_deactivate, join_room_by_id_helper, leave_room, remote_leave_room};
|
use api::client::{
|
||||||
|
full_user_deactivate, join_room_by_id_helper, leave_room, recreate_push_rules_and_return,
|
||||||
|
remote_leave_room,
|
||||||
|
};
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug_warn, error, info,
|
Err, Result, debug_warn, error, info,
|
||||||
matrix::{Event, pdu::PduBuilder},
|
matrix::{Event, pdu::PduBuilder},
|
||||||
@@ -1198,3 +1201,14 @@ pub(super) async fn change_email(&self, user_id: String, email: Option<String>)
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
|
pub(super) async fn reset_push_rules(&self, user_id: String) -> Result {
|
||||||
|
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||||
|
if !self.services.users.is_active(&user_id).await {
|
||||||
|
return Err!("User is not active.");
|
||||||
|
}
|
||||||
|
recreate_push_rules_and_return(self.services, &user_id).await?;
|
||||||
|
self.write_str("Reset user's push rules to the server default.")
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|||||||
@@ -257,4 +257,10 @@ pub enum UserCommand {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
yes_i_want_to_do_this: bool,
|
yes_i_want_to_do_this: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Resets the push-rules (notification settings) of the target user to the
|
||||||
|
/// server defaults.
|
||||||
|
ResetPushRules {
|
||||||
|
user_id: String,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ pub(super) use openid::*;
|
|||||||
pub(super) use presence::*;
|
pub(super) use presence::*;
|
||||||
pub(super) use profile::*;
|
pub(super) use profile::*;
|
||||||
pub use profile::{update_all_rooms, update_avatar_url, update_displayname};
|
pub use profile::{update_all_rooms, update_avatar_url, update_displayname};
|
||||||
|
pub use push::recreate_push_rules_and_return;
|
||||||
pub(super) use push::*;
|
pub(super) use push::*;
|
||||||
pub(super) use read_marker::*;
|
pub(super) use read_marker::*;
|
||||||
pub(super) use redact::*;
|
pub(super) use redact::*;
|
||||||
|
|||||||
@@ -489,7 +489,7 @@ pub(crate) async fn set_pushers_route(
|
|||||||
|
|
||||||
/// user somehow has bad push rules, these must always exist per spec.
|
/// user somehow has bad push rules, these must always exist per spec.
|
||||||
/// so recreate it and return server default silently
|
/// so recreate it and return server default silently
|
||||||
async fn recreate_push_rules_and_return(
|
pub async fn recreate_push_rules_and_return(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
sender_user: &ruma::UserId,
|
sender_user: &ruma::UserId,
|
||||||
) -> Result<get_pushrules_all::v3::Response> {
|
) -> Result<get_pushrules_all::v3::Response> {
|
||||||
|
|||||||
Reference in New Issue
Block a user