refactor(core): remove quark references from webhook routes

This commit is contained in:
Paul Makles
2023-09-03 15:52:18 +01:00
parent 5a9bb9e68d
commit 279d9ef1b5
18 changed files with 494 additions and 139 deletions

View File

@@ -402,6 +402,17 @@ impl From<crate::Interactions> for Interactions {
}
}
impl From<Interactions> for crate::Interactions {
fn from(value: Interactions) -> Self {
crate::Interactions {
reactions: value
.reactions
.map(|reactions| reactions.into_iter().collect()),
restrict_reactions: value.restrict_reactions,
}
}
}
impl From<crate::AppendMessage> for AppendMessage {
fn from(value: crate::AppendMessage) -> Self {
AppendMessage {
@@ -420,6 +431,16 @@ impl From<crate::Masquerade> for Masquerade {
}
}
impl From<Masquerade> for crate::Masquerade {
fn from(value: Masquerade) -> Self {
crate::Masquerade {
name: value.name,
avatar: value.avatar,
colour: value.colour,
}
}
}
impl From<crate::ServerBan> for ServerBan {
fn from(value: crate::ServerBan) -> Self {
ServerBan {

View File

@@ -7,7 +7,7 @@ use schemars::{
JsonSchema,
};
use crate::{Bot, Database, Webhook};
use crate::{Bot, Channel, Database, Webhook};
/// Reference to some object in the database
#[derive(Serialize, Deserialize)]
@@ -27,6 +27,11 @@ impl Reference {
db.fetch_bot(&self.id).await
}
/// Fetch channel from Ref
pub async fn as_channel(&self, db: &Database) -> Result<Channel> {
db.fetch_channel(&self.id).await
}
/// Fetch webhook from Ref
pub async fn as_webhook(&self, db: &Database) -> Result<Webhook> {
db.fetch_webhook(&self.id).await