summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar default2025-03-24 17:29:17 +0100
committerGravatar default2025-03-24 17:29:17 +0100
commit307aab92be9b9e0ea7676e05b1c752371ed0f7b9 (patch)
treec83b159dc6022fe36e4fb2a8c55df17403508e89 /html.c
parentUpdated TODO. (diff)
downloadpenes-snac2-307aab92be9b9e0ea7676e05b1c752371ed0f7b9.tar.gz
penes-snac2-307aab92be9b9e0ea7676e05b1c752371ed0f7b9.tar.xz
penes-snac2-307aab92be9b9e0ea7676e05b1c752371ed0f7b9.zip
In replace_shortnames(), avoid repeated emojis.
Diffstat (limited to 'html.c')
-rw-r--r--html.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/html.c b/html.c
index 78a9854..abb8562 100644
--- a/html.c
+++ b/html.c
@@ -72,6 +72,9 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
72 const xs_dict *v; 72 const xs_dict *v;
73 int c = 0; 73 int c = 0;
74 74
75 xs_set rep_emoji;
76 xs_set_init(&rep_emoji);
77
75 while (xs_list_next(tag_list, &v, &c)) { 78 while (xs_list_next(tag_list, &v, &c)) {
76 const char *t = xs_dict_get(v, "type"); 79 const char *t = xs_dict_get(v, "type");
77 80
@@ -79,6 +82,10 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
79 const char *n = xs_dict_get(v, "name"); 82 const char *n = xs_dict_get(v, "name");
80 const xs_dict *i = xs_dict_get(v, "icon"); 83 const xs_dict *i = xs_dict_get(v, "icon");
81 84
85 /* avoid repeated emojis (Misskey seems to return this) */
86 if (xs_set_add(&rep_emoji, n) == 0)
87 continue;
88
82 if (xs_is_string(n) && xs_is_dict(i)) { 89 if (xs_is_string(n) && xs_is_dict(i)) {
83 const char *u = xs_dict_get(i, "url"); 90 const char *u = xs_dict_get(i, "url");
84 const char *mt = xs_dict_get(i, "mediaType"); 91 const char *mt = xs_dict_get(i, "mediaType");
@@ -104,6 +111,8 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p
104 } 111 }
105 } 112 }
106 } 113 }
114
115 xs_set_free(&rep_emoji);
107 } 116 }
108 117
109 return s; 118 return s;