feat: add emoji
This commit is contained in:
@@ -30,4 +30,9 @@ impl File {
|
||||
db.find_and_use_attachment(id, "banners", "server", parent)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn use_emoji(db: &Database, id: &str, parent: &str) -> Result<File> {
|
||||
db.find_and_use_attachment(id, "emojis", "object", parent)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
36
crates/quark/src/impl/generic/media/emoji.rs
Normal file
36
crates/quark/src/impl/generic/media/emoji.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use crate::{
|
||||
events::client::EventV1,
|
||||
models::{emoji::EmojiParent, Emoji},
|
||||
Database, Result,
|
||||
};
|
||||
|
||||
impl Emoji {
|
||||
/// Get parent id
|
||||
fn parent(&self) -> &str {
|
||||
match &self.parent {
|
||||
EmojiParent::Server { id } => id,
|
||||
}
|
||||
}
|
||||
|
||||
/// Create an emoji
|
||||
pub async fn create(&self, db: &Database) -> Result<()> {
|
||||
db.insert_emoji(self).await?;
|
||||
EventV1::EmojiCreate(self.clone())
|
||||
.p(self.parent().to_string())
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Delete an emoji
|
||||
pub async fn delete(self, db: &Database) -> Result<()> {
|
||||
EventV1::EmojiDelete {
|
||||
id: self.id.to_string(),
|
||||
}
|
||||
.p(self.parent().to_string())
|
||||
.await;
|
||||
|
||||
db.mark_attachment_as_deleted(&self.id).await?;
|
||||
db.delete_emoji(&self).await
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ pub mod admin {
|
||||
|
||||
pub mod media {
|
||||
pub mod attachment;
|
||||
pub mod emoji;
|
||||
}
|
||||
|
||||
pub mod channels {
|
||||
|
||||
Reference in New Issue
Block a user