feat(core/database): system message helper

This commit is contained in:
Paul Makles
2023-08-05 17:03:16 +01:00
parent d04621b1d6
commit 3bfead4ff1
2 changed files with 19 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ use indexmap::{IndexMap, IndexSet};
use iso8601_timestamp::Timestamp;
use revolt_models::v0::{Embed, MessageSort, MessageWebhook};
use revolt_result::Result;
use ulid::Ulid;
use crate::{events::client::EventV1, Database, File};
@@ -194,6 +195,19 @@ impl Message {
}
}
impl SystemMessage {
pub fn into_message(self, channel: String) -> Message {
Message {
id: Ulid::new().to_string(),
channel,
author: "00000000000000000000000000".to_string(),
system: Some(self),
..Default::default()
}
}
}
impl Interactions {
/// Validate interactions info is correct
/* pub async fn validate(

View File

@@ -4,7 +4,7 @@ use revolt_result::{create_error, Result};
use crate::{
events::client::EventV1, util::permissions::DatabasePermissionQuery, Database, File, Server,
User,
SystemMessage, User,
};
auto_derived_partial!(
@@ -122,18 +122,18 @@ impl Member {
.private(user.id.clone())
.await;
if let Some(_id) = server
if let Some(id) = server
.system_messages
.as_ref()
.and_then(|x| x.user_joined.as_ref())
{
/* TODO: SystemMessage::UserJoined {
SystemMessage::UserJoined {
id: user.id.clone(),
}
.into_message(id.to_string())
.create_no_web_push(db, id, false)
.send_without_notifications(db)
.await
.ok(); */
.ok();
}
// Ok(channels)