Keep the casing pattern provided by the instance (#495)

This commit is contained in:
Humberto Rocha 2023-02-03 19:02:35 -05:00 committed by GitHub
parent d8113ed707
commit d8fc81a9a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -242,7 +242,7 @@ class Emoji(StatorModel):
emoji_hits = FediverseHtmlParser(
content, find_emojis=True, emoji_domain=domain
).emojis
emojis = sorted({emoji.lower() for emoji in emoji_hits})
emojis = sorted({emoji for emoji in emoji_hits})
return list(
cls.objects.filter(local=(domain is None) or domain.local)
.usable(domain)
@ -291,7 +291,7 @@ class Emoji(StatorModel):
raise ValueError("No mimetype on emoji JSON")
# create
shortcode = name.lower().strip(":")
shortcode = name.strip(":")
category = (icon.get("category") or "")[:100]
if not domain.local:

View file

@ -42,3 +42,20 @@ def test_emoji_ingestion(identity):
create=True,
)
assert emoji2.shortcode == "emoji2"
cased_emoji = Emoji.by_ap_tag(
identity.domain,
{
"icon": {
"type": "Image",
"url": "https://example.com/emoji/custom/CasedEmoji.png",
"mediaType": "image/png",
},
"id": "https://example.com/emoji/custom/CasedEmoji.png",
"nameMap": {"und": ":CasedEmoji:"},
"type": "Emoji",
"updated": "1970-01-01T00:00:00Z",
},
create=True,
)
assert cased_emoji.shortcode == "CasedEmoji"