R7 custom emoji: the server's own, added by administrators, sent on posts, profiles and reactions
LocalEmoji, a new collection (unique shortcode whatever its case, never renamed: the shortcode is its id elsewhere),
managed on /clientapi/admin/emoji/list|insert|update|delete and kept in the staff's log (emoji.insert, .update,
.delete). Its picture goes through IMediaService.EmojiImage: PNG, GIF, WebP or JPEG up to 256 KB, a PNG within 256 px
with alpha kept (an animated GIF or WebP stays an animated GIF, with a still PNG), keep=none, shrunk until it fits
GoToSocial's 100 KiB, held by ServerUse "emoji:<shortcode>" so the janitor and the audit leave it. LocalEmojis keeps the
offered ones in memory, reloaded on every change: GET /api/v1/custom_emojis is real; local posts (words, title, warning,
poll options, each revision) and profiles keep the emoji they name; Notes, Questions, actors and EmojiReacts carry
Mastodon's Emoji tag with its id, served as an Emoji at /emojis/{shortcode} (410 once deleted; the path awaits the
owner's confirmation); a persona reacts with one (Pleroma's reactions, announcements). A restore keeps the live emoji
as it keeps the settings, and trashes server pictures nothing holds. tools/pasture/scenarios/emoji.sh joins batch A.
Verified: built, and run locally against a scratch database (uploads of every type, animation kept, metadata gone,
refusals, rendering, reactions, history, announcements, delete and revive, backup and restore, media audit). The
pasture scenario and the sweep were not run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WpVCoDeM1qUTRp4fXQdfof
This commit is contained in:
1 parent
9f68ca3ed0
commit
d08fbabaa5
38 files changed
+1117
-54
No files matched your search
@@ -60,6 +60,10 @@ namespace PrivaPub.Models
|
||||
public const string AccountUnsuspend = "account.unsuspend";
|
||||
public const string GroupDelete = "group.delete";
|
||||
public const string PostRemove = "post.remove";
|
||||
// the server's custom emoji (completion program R7)
|
||||
public const string EmojiInsert = "emoji.insert";
|
||||
public const string EmojiUpdate = "emoji.update";
|
||||
public const string EmojiDelete = "emoji.delete";
|
||||
}
|
||||
|
||||
public static class AdminTargets
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using MongoDB.Entities;
|
||||
|
||||
namespace PrivaPub.Models.Post
|
||||
{
|
||||
// One of this server's own custom emoji (completion program R7), added by an administrator
|
||||
// (/clientapi/admin/emoji, EmojiAdminController). Its shortcode is its name everywhere: `:shortcode:` in a post, and
|
||||
// its federated id (/emojis/{shortcode}, Domain/Content/LocalEmojis.Path), which is why it is never renamed. Its picture
|
||||
// is a MediaAttachment nobody owns, held by ServerUse "emoji:<shortcode>" while the emoji exists. Deleted, the row stays
|
||||
// (DeletedAt) so its id answers 410; adding the same shortcode again brings the row back with a new picture.
|
||||
public class LocalEmoji : Entity
|
||||
{
|
||||
public string Shortcode { get; set; }//as written, [a-zA-Z0-9_]{2,64} (Mastodon's rule); matched exactly in texts
|
||||
public string Key { get; set; }//the shortcode in lower case: unique, so `Blob` and `blob` are never two emoji
|
||||
public string Category { get; set; }
|
||||
public bool VisibleInPicker { get; set; } = true;
|
||||
public bool Disabled { get; set; } = false;//kept, but offered nowhere and taken into no new post
|
||||
public string MediaId { get; set; }//its picture's MediaAttachment (ServerUse "emoji:<shortcode>")
|
||||
public string Url { get; set; }//the picture: a PNG, or an animated GIF
|
||||
public string StaticUrl { get; set; }//a still PNG of it (the first frame of a GIF; the picture itself otherwise)
|
||||
public string ContentType { get; set; }//image/png or image/gif
|
||||
public int? Width { get; set; }
|
||||
public int? Height { get; set; }
|
||||
public long Size { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;//any change
|
||||
public DateTime ImageUpdatedAt { get; set; } = DateTime.UtcNow;//its picture's: the Emoji's `updated`, which tells peers to fetch it again
|
||||
public DateTime? DeletedAt { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -160,5 +160,6 @@ namespace PrivaPub.Models.Post
|
||||
public string ContentHtml { get; set; }
|
||||
public bool HasContentWarning { get; set; }
|
||||
public DateTime EditedAt { get; set; }
|
||||
public List<CustomEmoji> Emojis { get; set; } = new();//the post's custom emoji in that version (none kept before R7)
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ namespace PrivaPub.Models.User
|
||||
public AvatarAccountState AccountState { get; set; } = AvatarAccountState.Normal;
|
||||
public AvatarSettings Settings { get; set; } = new();
|
||||
public Dictionary<string, string> Fields { get; set; } = new();
|
||||
// this server's custom emoji its name, bio and fields named when they were saved (R7, Domain/Content/LocalEmojis)
|
||||
public List<PrivaPub.Models.Post.CustomEmoji> Emojis { get; set; } = new();
|
||||
|
||||
public string Domain { get; set; }
|
||||
public string PersonalNote { get; set; }
|
||||
|
||||
Reference in new issue
Block a user