diff options
| author | 2022-10-17 11:59:11 +0200 | |
|---|---|---|
| committer | 2022-10-17 11:59:11 +0200 | |
| commit | c53052471e0b1e40a3251fab97be0eb16f3fa769 (patch) | |
| tree | e588925698d1da6c114fadc3b9d96fda7d820a48 | |
| parent | Updated documentation. (diff) | |
| download | snac2-c53052471e0b1e40a3251fab97be0eb16f3fa769.tar.gz snac2-c53052471e0b1e40a3251fab97be0eb16f3fa769.tar.xz snac2-c53052471e0b1e40a3251fab97be0eb16f3fa769.zip | |
Process :shortnames: in user names.
| -rw-r--r-- | html.c | 21 |
1 files changed, 20 insertions, 1 deletions
| @@ -54,7 +54,7 @@ d_char *html_msg_icon(snac *snac, d_char *os, char *msg) | |||
| 54 | if (actor_id && valid_status(actor_get(snac, actor_id, &actor))) { | 54 | if (actor_id && valid_status(actor_get(snac, actor_id, &actor))) { |
| 55 | xs *name = NULL; | 55 | xs *name = NULL; |
| 56 | xs *avatar = NULL; | 56 | xs *avatar = NULL; |
| 57 | char *v; | 57 | char *p, *v; |
| 58 | 58 | ||
| 59 | /* get the name */ | 59 | /* get the name */ |
| 60 | if (xs_is_null((v = xs_dict_get(actor, "name"))) || *v == '\0') { | 60 | if (xs_is_null((v = xs_dict_get(actor, "name"))) || *v == '\0') { |
| @@ -65,6 +65,25 @@ d_char *html_msg_icon(snac *snac, d_char *os, char *msg) | |||
| 65 | 65 | ||
| 66 | name = xs_dup(v); | 66 | name = xs_dup(v); |
| 67 | 67 | ||
| 68 | /* replace the :shortnames: */ | ||
| 69 | if (!xs_is_null(p = xs_dict_get(actor, "tag"))) { | ||
| 70 | /* iterate the tags */ | ||
| 71 | while (xs_list_iter(&p, &v)) { | ||
| 72 | char *t = xs_dict_get(v, "type"); | ||
| 73 | |||
| 74 | if (t && strcmp(t, "Emoji") == 0) { | ||
| 75 | char *n = xs_dict_get(v, "name"); | ||
| 76 | char *i = xs_dict_get(v, "icon"); | ||
| 77 | |||
| 78 | if (n && i) { | ||
| 79 | char *u = xs_dict_get(i, "url"); | ||
| 80 | |||
| 81 | name = xs_replace_i(name, n, u); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 68 | /* get the avatar */ | 87 | /* get the avatar */ |
| 69 | if ((v = xs_dict_get(actor, "icon")) != NULL && | 88 | if ((v = xs_dict_get(actor, "icon")) != NULL && |
| 70 | (v = xs_dict_get(v, "url")) != NULL) { | 89 | (v = xs_dict_get(v, "url")) != NULL) { |