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

View File

@@ -96,6 +96,36 @@ pub enum LegacyNotificationBody {
amount: String,
service: String,
},
PatCreated {
token_name: String,
},
ModerationMessageReceived {
project_id: ProjectId,
},
ReportStatusUpdated {
report_id: ReportId,
},
ReportSubmitted {
report_id: ReportId,
},
ProjectStatusApproved {
project_id: ProjectId,
},
ProjectStatusNeutral {
project_id: ProjectId,
old_status: ProjectStatus,
new_status: ProjectStatus,
},
ProjectTransferred {
project_id: ProjectId,
// Store only the raw identifiers in legacy body
new_owner_user_id: Option<UserId>,
new_owner_organization_id: Option<OrganizationId>,
},
PayoutAvailable {
amount: f64,
date_available: DateTime<Utc>,
},
Unknown,
}
@@ -117,6 +147,27 @@ impl LegacyNotification {
NotificationBody::ModeratorMessage { .. } => {
Some("moderator_message".to_string())
}
NotificationBody::PatCreated { .. } => {
Some("pat_created".to_string())
}
NotificationBody::ModerationMessageReceived { .. } => {
Some("moderation_message_received".to_string())
}
NotificationBody::ReportStatusUpdated { .. } => {
Some("report_status_updated".to_string())
}
NotificationBody::ReportSubmitted { .. } => {
Some("report_submitted".to_string())
}
NotificationBody::ProjectStatusApproved { .. } => {
Some("project_status_approved".to_string())
}
NotificationBody::ProjectStatusNeutral { .. } => {
Some("project_status_neutral".to_string())
}
NotificationBody::ProjectTransferred { .. } => {
Some("project_transferred".to_string())
}
NotificationBody::ResetPassword { .. } => {
Some("reset_password".to_string())
}
@@ -147,6 +198,9 @@ impl LegacyNotification {
NotificationBody::PaymentFailed { .. } => {
Some("payment_failed".to_string())
}
NotificationBody::PayoutAvailable { .. } => {
Some("payout_available".to_string())
}
NotificationBody::LegacyMarkdown {
notification_type, ..
} => notification_type.clone(),
@@ -203,6 +257,46 @@ impl LegacyNotification {
project_id,
report_id,
},
NotificationBody::PatCreated { token_name } => {
LegacyNotificationBody::PatCreated { token_name }
}
NotificationBody::ModerationMessageReceived { project_id } => {
LegacyNotificationBody::ModerationMessageReceived { project_id }
}
NotificationBody::ReportStatusUpdated { report_id } => {
LegacyNotificationBody::ReportStatusUpdated { report_id }
}
NotificationBody::ReportSubmitted { report_id } => {
LegacyNotificationBody::ReportSubmitted { report_id }
}
NotificationBody::ProjectStatusApproved { project_id } => {
LegacyNotificationBody::ProjectStatusApproved { project_id }
}
NotificationBody::ProjectStatusNeutral {
project_id,
old_status,
new_status,
} => LegacyNotificationBody::ProjectStatusNeutral {
project_id,
old_status,
new_status,
},
NotificationBody::ProjectTransferred {
project_id,
new_owner_user_id,
new_owner_organization_id,
} => LegacyNotificationBody::ProjectTransferred {
project_id,
new_owner_user_id,
new_owner_organization_id,
},
NotificationBody::PayoutAvailable {
amount,
date_available,
} => LegacyNotificationBody::PayoutAvailable {
amount,
date_available,
},
NotificationBody::LegacyMarkdown {
notification_type,
name,