summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.c2
-rw-r--r--format.c20
-rw-r--r--mastoapi.c32
-rw-r--r--snac.h1
4 files changed, 44 insertions, 11 deletions
diff --git a/activitypub.c b/activitypub.c
index 829f6d5..1992b13 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1611,7 +1611,7 @@ xs_dict *msg_emoji_init(snac *snac, const char *mid, const char *eid_o)
1611 xs *dict = xs_dict_new(); 1611 xs *dict = xs_dict_new();
1612 xs *icon = xs_dict_new(); 1612 xs *icon = xs_dict_new();
1613 xs *accounts = xs_list_new(); 1613 xs *accounts = xs_list_new();
1614 xs *emjs = emojis(); 1614 xs *emjs = emojis_rm_categories();
1615 1615
1616 /* may be a default emoji */ 1616 /* may be a default emoji */
1617 xs *eidd = xs_dup(eid); 1617 xs *eidd = xs_dup(eid);
diff --git a/format.c b/format.c
index 803e5a5..95c1b12 100644
--- a/format.c
+++ b/format.c
@@ -79,6 +79,24 @@ xs_dict *emojis(void)
79 return d; 79 return d;
80} 80}
81 81
82
83xs_dict *emojis_rm_categories() {
84 xs *emjs = emojis();
85 char *res = xs_dict_new();
86 const char *k, *v;
87 xs_dict_foreach(emjs, k, v) {
88 if (xs_type(v) == XSTYPE_DICT) {
89 const char *v2;
90 xs_dict_foreach(v, k, v2)
91 res = xs_dict_append(res, k, v2);
92 }
93 else
94 res = xs_dict_append(res, k, v);
95 }
96 return res;
97}
98
99
82/* Non-whitespace without trailing comma, period or closing paren */ 100/* Non-whitespace without trailing comma, period or closing paren */
83#define NOSPACE "([^[:space:],.)]+|[,.)]+[^[:space:],.)])+" 101#define NOSPACE "([^[:space:],.)]+|[,.)]+[^[:space:],.)])+"
84 102
@@ -405,7 +423,7 @@ xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag
405 423
406 { 424 {
407 /* traditional emoticons */ 425 /* traditional emoticons */
408 xs *d = emojis(); 426 xs *d = emojis_rm_categories();
409 int c = 0; 427 int c = 0;
410 const char *k, *v; 428 const char *k, *v;
411 429
diff --git a/mastoapi.c b/mastoapi.c
index 8187115..dd80abc 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -2647,19 +2647,33 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2647 if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/ 2647 if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/
2648 xs *emo = emojis(); 2648 xs *emo = emojis();
2649 xs *list = xs_list_new(); 2649 xs *list = xs_list_new();
2650 int c = 0;
2651 const xs_str *k; 2650 const xs_str *k;
2652 const xs_val *v; 2651 const xs_val *v;
2653 while(xs_dict_next(emo, &k, &v, &c)) { 2652 xs_dict_foreach(emo, k, v) {
2654 xs *current = xs_dict_new(); 2653 xs *current = xs_dict_new();
2655 if (xs_startswith(v, "https://") && xs_startswith((xs_mime_by_ext(v)), "image/")) { 2654 if ((xs_startswith(v, "https://") && xs_startswith((xs_mime_by_ext(v)), "image/")) || xs_type(v) == XSTYPE_DICT) {
2656 /* remove first and last colon */ 2655 /* remove first and last colon */
2657 xs *shortcode = xs_replace(k, ":", ""); 2656 if (xs_type(v) == XSTYPE_DICT) {
2658 current = xs_dict_append(current, "shortcode", shortcode); 2657 const char *v2;
2659 current = xs_dict_append(current, "url", v); 2658 const char *cat = k;
2660 current = xs_dict_append(current, "static_url", v); 2659 xs_dict_foreach(v, k, v2) {
2661 current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE)); 2660 xs *shortcode = xs_replace(k, ":", "");
2662 list = xs_list_append(list, current); 2661 current = xs_dict_append(current, "shortcode", shortcode);
2662 current = xs_dict_append(current, "url", v2);
2663 current = xs_dict_append(current, "static_url", v2);
2664 current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE));
2665 current = xs_dict_append(current, "category", cat);
2666 list = xs_list_append(list, current);
2667 }
2668 }
2669 else {
2670 xs *shortcode = xs_replace(k, ":", "");
2671 current = xs_dict_append(current, "shortcode", shortcode);
2672 current = xs_dict_append(current, "url", v);
2673 current = xs_dict_append(current, "static_url", v);
2674 current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE));
2675 list = xs_list_append(list, current);
2676 }
2663 } 2677 }
2664 } 2678 }
2665 *body = xs_json_dumps(list, 0); 2679 *body = xs_json_dumps(list, 0);
diff --git a/snac.h b/snac.h
index e5efc0b..d57391f 100644
--- a/snac.h
+++ b/snac.h
@@ -412,6 +412,7 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
412 char **body, int *b_size, char **ctype); 412 char **body, int *b_size, char **ctype);
413 413
414xs_dict *emojis(void); 414xs_dict *emojis(void);
415xs_dict *emojis_rm_categories(void);
415xs_str *format_text_with_emoji(snac *user, const char *text, int ems, const char *proxy); 416xs_str *format_text_with_emoji(snac *user, const char *text, int ems, const char *proxy);
416xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag); 417xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag);
417xs_str *sanitize(const char *content); 418xs_str *sanitize(const char *content);