1use crate::common::file::{ExternalFileObject, FileObject, FileOrEmojiObject};
2use reqwest::Url;
3
4impl FileOrEmojiObject {
5 pub fn emoji_from_shortcode(name: &str) -> Self {
6 let default = FileOrEmojiObject::Emoji {
7 emoji: String::new(),
8 };
9 if let Some(e) = emojis::get_by_shortcode(name) {
10 return FileOrEmojiObject::Emoji {
11 emoji: e.to_string(),
12 };
13 }
14 default
15 }
16 pub fn external_file_from_url(url: Url) -> Self {
17 FileOrEmojiObject::External {
18 external: ExternalFileObject {
19 url: url.to_string(),
20 },
21 }
22 }
23}
24
25impl FileObject {
26 pub fn external_file_from_url(url: Url) -> Self {
27 FileObject::External {
28 external: ExternalFileObject {
29 url: url.to_string(),
30 },
31 }
32 }
33}