allow sending emoji/stickers from emote packs

This commit is contained in:
Henry Hiles 2026-10-23 18:16:45 -04:00
commit 3754bc2feb
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -0,0 +1,33 @@
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:freezed_annotation/freezed_annotation.dart";
import "package:nexus/models/content/image_pack.dart";
part "image_pack.freezed.dart";
@Freezed(toJson: false, fromJson: false)
class const ImagePack({
required final String id,
required final String name,
final Uri? avatar,
/// Map of shortcode to images
required final IMap<String, PackImage> emoticons,
required final IMap<String, PackImage> stickers,
}) with _$ImagePack {
static String emojiMarkdown(String shortcode, String url) {
final title = ":$shortcode:".replaceAll(r"\", r"\\").replaceAll('"', r'\"');
return '![:$shortcode:]($url "Emoji: $title")';
}
factory ImagePack.fromContent(
ImagePackContent content, {
required String id,
required String fallbackName,
}) => .new(
id: id,
name: content.pack?.displayName ?? fallbackName,
avatar: content.pack?.avatarUrl,
emoticons: content.imagesFor(.emoticon),
stickers: content.imagesFor(.sticker),
);
}