mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-06-26 08:15:22 +02:00
feat: Allow mentioning @room in an admin announcement
Some checks failed
Documentation / Build and Deploy Documentation (push) Failing after 3s
Rust Checks / Format (push) Failing after 3s
Rust Checks / Clippy (push) Failing after 9s
Rust Checks / Cargo Test (push) Failing after 10s
Release Docker Image / define-variables (push) Failing after 4s
Release Docker Image / build-image (linux/amd64, linux-amd64) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, linux-arm64) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Some checks failed
Documentation / Build and Deploy Documentation (push) Failing after 3s
Rust Checks / Format (push) Failing after 3s
Rust Checks / Clippy (push) Failing after 9s
Rust Checks / Cargo Test (push) Failing after 10s
Release Docker Image / define-variables (push) Failing after 4s
Release Docker Image / build-image (linux/amd64, linux-amd64) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, linux-arm64) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
This commit is contained in:
parent
5d44653e3a
commit
d0f00e6f5c
2 changed files with 22 additions and 15 deletions
8
docs/static/announcements.schema.json
vendored
8
docs/static/announcements.schema.json
vendored
|
@ -3,7 +3,7 @@
|
|||
"$id": "https://continwuity.org/schema/announcements.schema.json",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"updates": {
|
||||
"announcements": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
|
@ -16,6 +16,10 @@
|
|||
},
|
||||
"date": {
|
||||
"type": "string"
|
||||
},
|
||||
"mention_room": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to mention the room (@room) when posting this announcement"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
@ -26,6 +30,6 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"updates"
|
||||
"announcements"
|
||||
]
|
||||
}
|
|
@ -20,7 +20,7 @@ use std::{sync::Arc, time::Duration};
|
|||
use async_trait::async_trait;
|
||||
use conduwuit::{Result, Server, debug, info, warn};
|
||||
use database::{Deserialized, Map};
|
||||
use ruma::events::room::message::RoomMessageEventContent;
|
||||
use ruma::events::{Mentions, room::message::RoomMessageEventContent};
|
||||
use serde::Deserialize;
|
||||
use tokio::{
|
||||
sync::Notify,
|
||||
|
@ -53,6 +53,8 @@ struct CheckForAnnouncementsResponseEntry {
|
|||
id: u64,
|
||||
date: Option<String>,
|
||||
message: String,
|
||||
#[serde(default, skip_serializing_if = "bool::not")]
|
||||
mention_room: bool,
|
||||
}
|
||||
|
||||
const CHECK_FOR_ANNOUNCEMENTS_URL: &str =
|
||||
|
@ -139,19 +141,20 @@ impl Service {
|
|||
} else {
|
||||
info!("[announcements] {:#}", announcement.message);
|
||||
}
|
||||
let mut message = RoomMessageEventContent::text_markdown(format!(
|
||||
"### New announcement{}\n\n{}",
|
||||
announcement
|
||||
.date
|
||||
.as_ref()
|
||||
.map_or_else(String::new, |date| format!(" - `{date}`")),
|
||||
announcement.message
|
||||
));
|
||||
|
||||
self.services
|
||||
.admin
|
||||
.send_message(RoomMessageEventContent::text_markdown(format!(
|
||||
"### New announcement{}\n\n{}",
|
||||
announcement
|
||||
.date
|
||||
.as_ref()
|
||||
.map_or_else(String::new, |date| format!(" - `{date}`")),
|
||||
announcement.message
|
||||
)))
|
||||
.await
|
||||
.ok();
|
||||
if announcement.mention_room {
|
||||
message = message.add_mentions(Mentions::with_room_mention());
|
||||
}
|
||||
|
||||
self.services.admin.send_message(message).await.ok();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Reference in a new issue