mirror of
https://github.com/element-hq/matrix-authentication-service.git
synced 2026-10-13 04:49:29 +00:00
Add a manage send-room-invites command
Schedules a `SendRoomInviteEmailsJob` from the command line, so the room invite emails can be triggered by hand without an API caller. A worker has to be running to actually send them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
734734e076
commit
4872e25929
@@ -25,7 +25,7 @@ use mas_storage::{
|
||||
oauth2::OAuth2SessionFilter,
|
||||
queue::{
|
||||
DeactivateUserJob, ProvisionUserJob, QueueJobRepositoryExt as _, ReactivateUserJob,
|
||||
SyncDevicesJob,
|
||||
SendRoomInviteEmailsJob, SyncDevicesJob,
|
||||
},
|
||||
user::{
|
||||
BrowserSessionFilter, UserEmailRepository, UserFilter, UserPasswordRepository,
|
||||
@@ -230,6 +230,16 @@ enum Subcommand {
|
||||
#[clap(long)]
|
||||
ignore_password_complexity: bool,
|
||||
},
|
||||
|
||||
/// Send a room invite email to a list of addresses
|
||||
SendRoomInvites {
|
||||
/// The room to invite the recipients to
|
||||
room_id: String,
|
||||
|
||||
/// The addresses to invite
|
||||
#[arg(required = true)]
|
||||
emails: Vec<String>,
|
||||
},
|
||||
}
|
||||
|
||||
impl Options {
|
||||
@@ -569,6 +579,29 @@ impl Options {
|
||||
Ok(ExitCode::SUCCESS)
|
||||
}
|
||||
|
||||
SC::SendRoomInvites { room_id, emails } => {
|
||||
let _span = info_span!(
|
||||
"cli.manage.send_room_invites",
|
||||
room.id = room_id,
|
||||
recipients.count = emails.len(),
|
||||
)
|
||||
.entered();
|
||||
let database_config = DatabaseConfig::extract_or_default(figment)
|
||||
.map_err(anyhow::Error::from_boxed)?;
|
||||
let mut conn = database_connection_from_config(&database_config).await?;
|
||||
let txn = conn.begin().await?;
|
||||
let mut repo = PgRepository::from_conn(txn);
|
||||
|
||||
let job = SendRoomInviteEmailsJob::new(room_id, emails);
|
||||
repo.queue_job().schedule_job(&mut rng, &clock, job).await?;
|
||||
|
||||
repo.into_inner().commit().await?;
|
||||
|
||||
info!("Scheduled the room invite emails. A worker must be running to send them.");
|
||||
|
||||
Ok(ExitCode::SUCCESS)
|
||||
}
|
||||
|
||||
SC::KillSessions { username, dry_run } => {
|
||||
let _span =
|
||||
info_span!("cli.manage.kill_sessions", user.username = username).entered();
|
||||
|
||||
@@ -151,3 +151,16 @@ Options:
|
||||
$ mas-cli manage register-user
|
||||
$ mas-cli manage register-user --yes <username>
|
||||
```
|
||||
|
||||
## `manage send-room-invites`
|
||||
|
||||
Send a room invite email to a list of addresses. This schedules the job; a
|
||||
worker must be running to actually send the emails.
|
||||
|
||||
Arguments:
|
||||
- `<room_id>`: The room to invite the recipients to.
|
||||
- `<emails>...`: The addresses to invite. At least one is required.
|
||||
|
||||
```
|
||||
$ mas-cli manage send-room-invites '!room:example.com' alice@example.com bob@example.com
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user