New Creator Notifications (#4383)

* Some new notification types

* Fix error

* Use existing DB models rather than inline queries

* Fix template fillout

* Fix ModerationThreadMessageReceived

* Insert more notifications, fix some formatting

* chore: query cache, clippy, fmt

* chore: query cache, clippy, fmt

* Use outer transactions to insert notifications instead of creating a new one

* Join futures
This commit is contained in:
François-Xavier Talbot
2025-09-17 15:37:21 -04:00
committed by GitHub
parent 8149618187
commit 6da190ed01
25 changed files with 1211 additions and 77 deletions
+19
View File
@@ -1,6 +1,7 @@
use crate::auth::{check_is_moderator_from_headers, get_user_from_headers};
use crate::database;
use crate::database::models::image_item;
use crate::database::models::notification_item::NotificationBuilder;
use crate::database::models::thread_item::{
ThreadBuilder, ThreadMessageBuilder,
};
@@ -8,6 +9,7 @@ use crate::database::redis::RedisPool;
use crate::models::ids::ImageId;
use crate::models::ids::{ProjectId, VersionId};
use crate::models::images::{Image, ImageContext};
use crate::models::notifications::NotificationBody;
use crate::models::pats::Scopes;
use crate::models::reports::{ItemType, Report};
use crate::models::threads::{MessageBody, ThreadType};
@@ -204,6 +206,15 @@ pub async fn report_create(
.insert(&mut transaction)
.await?;
// Notify the reporter that the report has been submitted
NotificationBuilder {
body: NotificationBody::ReportSubmitted {
report_id: id.into(),
},
}
.insert(current_user.id.into(), &mut transaction, &redis)
.await?;
transaction.commit().await?;
Ok(HttpResponse::Ok().json(Report {
@@ -455,6 +466,14 @@ pub async fn report_edit(
.insert(&mut transaction)
.await?;
NotificationBuilder {
body: NotificationBody::ReportStatusUpdated {
report_id: id.into(),
},
}
.insert(report.reporter, &mut transaction, &redis)
.await?;
sqlx::query!(
"
UPDATE reports