chore (backend-rs): add misc::emoji submodule

This commit is contained in:
naskya 2024-08-04 12:07:02 +09:00
parent 17a9ff6bf1
commit 2a6fb45d66
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
7 changed files with 13 additions and 3 deletions

View file

@ -1,5 +1,5 @@
use super::*;
use crate::{config::CONFIG, model::entity::emoji};
use crate::{model::entity::emoji, misc};
use chrono::Utc;
#[macros::export(object)]
@ -24,7 +24,7 @@ impl ApEmoji {
#[allow(dead_code)] // TODO: remove this line
fn new(emoji: emoji::Model) -> Self {
Self {
id: format!("{}/emojis/{}", CONFIG.url, emoji.name),
id: misc::emoji::local_uri(&emoji.name),
r#type: ApObject::Emoji,
name: format!(":{}:", emoji.name),
updated: emoji

View file

@ -0,0 +1,9 @@
pub mod emoji;
pub mod reaction;
use crate::config::CONFIG;
/// Returns URI of a local custom emoji.
pub fn local_uri(emoji_code: impl std::fmt::Display) -> String {
format!("{}/emojis/{}", CONFIG.url, emoji_code)
}

View file

@ -14,7 +14,6 @@ pub mod note;
pub mod nyaify;
pub mod password;
pub mod random_icon;
pub mod reaction;
pub mod remove_old_attestation_challenges;
pub mod should_nyaify;
pub mod system_info;

View file

@ -6,6 +6,7 @@ pub mod summarize;
use crate::config::CONFIG;
/// Returns URI of a local post.
pub fn local_uri(note_id: impl std::fmt::Display) -> String {
format!("{}/notes/{}", CONFIG.url, note_id)
}

View file

@ -2,6 +2,7 @@ pub mod count;
use crate::config::CONFIG;
/// Returns URI of a local user.
pub fn local_uri(user_id: impl std::fmt::Display) -> String {
format!("{}/users/{}", CONFIG.url, user_id)
}