[PR #725] [MERGED] Convert mailer_emoji JSON file to map #1393

Closed
opened 2026-05-07 01:01:54 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/725
Author: @adamantike
Created: 5/13/2023
Status: Merged
Merged: 5/14/2023
Merged by: @binwiederhier

Base: mainHead: misc/migrate-mailer-emoji-json-to-map


📝 Commits (1)

  • 49bd612 Convert mailer_emoji JSON file to map

📊 Changes

3 files changed (+1868 additions, -19 deletions)

View changed files

server/mailer_emoji.json (+0 -1)
server/mailer_emoji_map.json (+1857 -0)
📝 server/smtp_sender.go (+11 -18)

📄 Description

This fixes a pending TODO comment regarding inefficient tags to emojis mapping, by requiring a full scan over emoji aliases to determine matches.

Instead, now the JSON file is a map, with aliases as keys, and emojis as values. The script to convert the file with Python was:

import json

with open("./server/mailer_emoji.json", "r", encoding="utf-8") as f:
    content = json.load(f)

emoji_map = {}
for emoji in content:
    for alias in emoji["aliases"]:
        if alias in emoji_map:
            print("WARNING: Duplicate alias:", alias)
            continue
        emoji_map[alias] = emoji["emoji"]

sorted_emoji_map = {k: emoji_map[k] for k in sorted(emoji_map)}

with open("./server/mailer_emoji_map.json", "w", encoding="utf-8") as f:
    json.dump(sorted_emoji_map, f, indent=4, ensure_ascii=False)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/binwiederhier/ntfy/pull/725 **Author:** [@adamantike](https://github.com/adamantike) **Created:** 5/13/2023 **Status:** ✅ Merged **Merged:** 5/14/2023 **Merged by:** [@binwiederhier](https://github.com/binwiederhier) **Base:** `main` ← **Head:** `misc/migrate-mailer-emoji-json-to-map` --- ### 📝 Commits (1) - [`49bd612`](https://github.com/binwiederhier/ntfy/commit/49bd6129fff092951a317cc46ac923f3fc8aaef1) Convert mailer_emoji JSON file to map ### 📊 Changes **3 files changed** (+1868 additions, -19 deletions) <details> <summary>View changed files</summary> ➖ `server/mailer_emoji.json` (+0 -1) ➕ `server/mailer_emoji_map.json` (+1857 -0) 📝 `server/smtp_sender.go` (+11 -18) </details> ### 📄 Description This fixes a pending TODO comment regarding inefficient tags to emojis mapping, by requiring a full scan over emoji aliases to determine matches. Instead, now the JSON file is a map, with aliases as keys, and emojis as values. The script to convert the file with Python was: ```python import json with open("./server/mailer_emoji.json", "r", encoding="utf-8") as f: content = json.load(f) emoji_map = {} for emoji in content: for alias in emoji["aliases"]: if alias in emoji_map: print("WARNING: Duplicate alias:", alias) continue emoji_map[alias] = emoji["emoji"] sorted_emoji_map = {k: emoji_map[k] for k in sorted(emoji_map)} with open("./server/mailer_emoji_map.json", "w", encoding="utf-8") as f: json.dump(sorted_emoji_map, f, indent=4, ensure_ascii=False) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 01:01:54 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1393
No description provided.