You've already forked AstralRinth
feat: access labrinth backend (#6284)
* feat: redirect `/hosting` to archon * feat: server invite notification type * feat: direct email notification endpoint * feat: revoke notification endpoint * feat: specify users to remove notifications from * refactor: insert notifications before sending emails * refactor: rename endpoint * refactor: remove archon redirect * style: mark field unused * feat: dedup external notifications * feat: add server invite email templates * style: remove unnecessary format --------- Co-authored-by: sychic <47618543+Sychic@users.noreply.github.com>
This commit is contained in:
@@ -11,6 +11,7 @@ use crate::models::{
|
||||
use ariadne::ids::UserId;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct LegacyNotification {
|
||||
@@ -66,6 +67,12 @@ pub enum LegacyNotificationBody {
|
||||
team_id: TeamId,
|
||||
role: String,
|
||||
},
|
||||
ServerInvite {
|
||||
server_id: Uuid,
|
||||
server_name: String,
|
||||
invited_by: UserId,
|
||||
role: String,
|
||||
},
|
||||
StatusChange {
|
||||
project_id: ProjectId,
|
||||
old_status: ProjectStatus,
|
||||
@@ -166,6 +173,9 @@ impl LegacyNotification {
|
||||
NotificationBody::OrganizationInvite { .. } => {
|
||||
Some("organization_invite".to_string())
|
||||
}
|
||||
NotificationBody::ServerInvite { .. } => {
|
||||
Some("server_invite".to_string())
|
||||
}
|
||||
NotificationBody::StatusChange { .. } => {
|
||||
Some("status_change".to_string())
|
||||
}
|
||||
@@ -269,6 +279,17 @@ impl LegacyNotification {
|
||||
team_id,
|
||||
role,
|
||||
},
|
||||
NotificationBody::ServerInvite {
|
||||
server_id,
|
||||
server_name,
|
||||
invited_by,
|
||||
role,
|
||||
} => LegacyNotificationBody::ServerInvite {
|
||||
server_id,
|
||||
server_name,
|
||||
invited_by,
|
||||
role,
|
||||
},
|
||||
NotificationBody::StatusChange {
|
||||
project_id,
|
||||
old_status,
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::routes::ApiError;
|
||||
use ariadne::ids::UserId;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Notification {
|
||||
@@ -34,6 +35,7 @@ pub enum NotificationType {
|
||||
ProjectUpdate,
|
||||
TeamInvite,
|
||||
OrganizationInvite,
|
||||
ServerInvite,
|
||||
StatusChange,
|
||||
ModeratorMessage,
|
||||
LegacyMarkdown,
|
||||
@@ -67,6 +69,7 @@ impl NotificationType {
|
||||
NotificationType::ProjectUpdate => "project_update",
|
||||
NotificationType::TeamInvite => "team_invite",
|
||||
NotificationType::OrganizationInvite => "organization_invite",
|
||||
NotificationType::ServerInvite => "server_invite",
|
||||
NotificationType::StatusChange => "status_change",
|
||||
NotificationType::ModeratorMessage => "moderator_message",
|
||||
NotificationType::LegacyMarkdown => "legacy_markdown",
|
||||
@@ -104,6 +107,7 @@ impl NotificationType {
|
||||
"project_update" => NotificationType::ProjectUpdate,
|
||||
"team_invite" => NotificationType::TeamInvite,
|
||||
"organization_invite" => NotificationType::OrganizationInvite,
|
||||
"server_invite" => NotificationType::ServerInvite,
|
||||
"status_change" => NotificationType::StatusChange,
|
||||
"moderator_message" => NotificationType::ModeratorMessage,
|
||||
"legacy_markdown" => NotificationType::LegacyMarkdown,
|
||||
@@ -156,6 +160,12 @@ pub enum NotificationBody {
|
||||
team_id: TeamId,
|
||||
role: String,
|
||||
},
|
||||
ServerInvite {
|
||||
server_id: Uuid,
|
||||
server_name: String,
|
||||
invited_by: UserId,
|
||||
role: String,
|
||||
},
|
||||
StatusChange {
|
||||
project_id: ProjectId,
|
||||
old_status: ProjectStatus,
|
||||
@@ -267,6 +277,9 @@ impl NotificationBody {
|
||||
NotificationBody::OrganizationInvite { .. } => {
|
||||
NotificationType::OrganizationInvite
|
||||
}
|
||||
NotificationBody::ServerInvite { .. } => {
|
||||
NotificationType::ServerInvite
|
||||
}
|
||||
NotificationBody::StatusChange { .. } => {
|
||||
NotificationType::StatusChange
|
||||
}
|
||||
@@ -418,6 +431,34 @@ impl From<DBNotification> for Notification {
|
||||
},
|
||||
],
|
||||
),
|
||||
NotificationBody::ServerInvite {
|
||||
server_id: _,
|
||||
server_name,
|
||||
role,
|
||||
..
|
||||
} => (
|
||||
"You have been invited to join a server!".to_string(),
|
||||
format!(
|
||||
"An invite has been sent for you to be {role} of {server_name}"
|
||||
),
|
||||
"#".to_string(),
|
||||
vec![
|
||||
NotificationAction {
|
||||
name: "Accept".to_string(),
|
||||
action_route: (
|
||||
"POST".to_string(),
|
||||
String::new(),
|
||||
),
|
||||
},
|
||||
NotificationAction {
|
||||
name: "Deny".to_string(),
|
||||
action_route: (
|
||||
"POST".to_string(),
|
||||
String::new(),
|
||||
),
|
||||
},
|
||||
],
|
||||
),
|
||||
NotificationBody::StatusChange {
|
||||
old_status,
|
||||
new_status,
|
||||
|
||||
Reference in New Issue
Block a user