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
@@ -0,0 +1,45 @@
|
||||
using PrivaPub.ClientModels.Resources;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace PrivaPub.ClientModels.Admin
|
||||
{
|
||||
// one of the server's custom emoji as the administrator's page shows it (/clientapi/admin/emoji/list, completion program
|
||||
// R7): disabled ones too, deleted ones never
|
||||
public class ViewLocalEmoji
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Shortcode { get; set; }
|
||||
public string Category { get; set; }
|
||||
public bool VisibleInPicker { get; set; } = true;
|
||||
public bool Disabled { get; set; } = false;
|
||||
public string Url { get; set; }//its picture: a PNG, or an animated GIF
|
||||
public string StaticUrl { get; set; }//a still PNG of it
|
||||
public string ContentType { get; set; }
|
||||
public int? Width { get; set; }
|
||||
public int? Height { get; set; }
|
||||
public long Size { get; set; } = 0;
|
||||
public string Uri { get; set; }//its id on other servers (/emojis/{shortcode}): why a shortcode never changes
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
public DateTime ImageUpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
// POST /clientapi/admin/emoji/insert and /emoji/update, as multipart/form-data with the picture as `image` (PNG, GIF,
|
||||
// WebP or JPEG, 256 KB at most; required to insert, optional to update). The shortcode names the emoji: an update
|
||||
// changes the emoji with that shortcode, and an emoji is never renamed (its shortcode is its id elsewhere); an update
|
||||
// sends the emoji as it should be, its category (none when empty), whether it is in the picker and whether it is
|
||||
// disabled.
|
||||
public class LocalEmojiForm
|
||||
{
|
||||
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorsResource)),
|
||||
RegularExpression(Constants.ShortcodeRegex, ErrorMessageResourceName = "InvalidShortcode", ErrorMessageResourceType = typeof(ErrorsResource))]
|
||||
public string Shortcode { get; set; }
|
||||
|
||||
[StringLength(64, ErrorMessageResourceName = "MaxLengthString", ErrorMessageResourceType = typeof(ErrorsResource))]
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,7 @@
|
||||
|
||||
public const string PasswordRegex = @"^(?=.*)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$";
|
||||
public const string UserNameRegex = "^[a-z0-9_]+$";
|
||||
// a custom emoji's shortcode: Mastodon's rule (letters, digits and underscores, two at least), 64 at most
|
||||
public const string ShortcodeRegex = "^[a-zA-Z0-9_]{2,64}$";
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,15 @@ namespace PrivaPub.ClientModels.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Use only letters, digits and underscores, from 2 to 64 of them..
|
||||
/// </summary>
|
||||
public static string InvalidShortcode {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidShortcode", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Invalid password, upper-case, lower-case and number characters required..
|
||||
/// </summary>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="InvalidUserName" xml:space="preserve">
|
||||
<value>Usa solo lettere minuscole, cifre e trattini bassi.</value>
|
||||
</data>
|
||||
<data name="InvalidShortcode" xml:space="preserve">
|
||||
<value>Usa solo lettere, cifre e trattini bassi, da 2 a 64.</value>
|
||||
</data>
|
||||
<data name="InvalidPassword" xml:space="preserve">
|
||||
<value>Password non valida, deve avere almeno un carattere grande, un carattere piccolo ed un numero.</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="InvalidUserName" xml:space="preserve">
|
||||
<value>Use only lower-case letters, digits and underscores.</value>
|
||||
</data>
|
||||
<data name="InvalidShortcode" xml:space="preserve">
|
||||
<value>Use only letters, digits and underscores, from 2 to 64 of them.</value>
|
||||
</data>
|
||||
<data name="InvalidPassword" xml:space="preserve">
|
||||
<value>Invalid password, upper-case, lower-case and number characters required.</value>
|
||||
</data>
|
||||
|
||||
Reference in new issue
Block a user