summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorGravatar default2024-01-11 06:08:52 +0100
committerGravatar default2024-01-11 06:08:52 +0100
commiteacfa5b7518ccbf7d88db0f2623d526b17e28e6f (patch)
tree327d9ff62d8f943d6a59b07ca930a7b9cda02374 /activitypub.c
parentUpdated RELEASE_NOTES. (diff)
downloadsnac2-eacfa5b7518ccbf7d88db0f2623d526b17e28e6f.tar.gz
snac2-eacfa5b7518ccbf7d88db0f2623d526b17e28e6f.tar.xz
snac2-eacfa5b7518ccbf7d88db0f2623d526b17e28e6f.zip
Avoid a webfinger request in msg_note().
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/activitypub.c b/activitypub.c
index 7c5a19e..8383f9b 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1204,18 +1204,25 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
1204 to = xs_list_append(to, a); 1204 to = xs_list_append(to, a);
1205 1205
1206 /* add this author to the tag list as a mention */ 1206 /* add this author to the tag list as a mention */
1207 xs *t_href = NULL; 1207 if (!xs_is_null(a)) {
1208 xs *t_name = NULL; 1208 xs *l = xs_split(a, "/");
1209 xs *actor_o = NULL;
1209 1210
1210 if (!xs_is_null(a) && valid_status(webfinger_request(a, &t_href, &t_name) 1211 if (xs_list_len(l) > 3 && valid_status(object_get(a, &actor_o))) {
1211 && t_href && t_name)) { 1212 char *uname = xs_dict_get(actor_o, "preferredUsername");
1212 xs *t = xs_dict_new();
1213 1213
1214 t = xs_dict_append(t, "type", "Mention"); 1214 if (!xs_is_null(uname) && *uname) {
1215 t = xs_dict_append(t, "href", t_href); 1215 xs *handle = xs_fmt("@%s@%s", uname, xs_list_get(l, 2));
1216 t = xs_dict_append(t, "name", t_name);
1217 1216
1218 tag = xs_list_append(tag, t); 1217 xs *t = xs_dict_new();
1218
1219 t = xs_dict_append(t, "type", "Mention");
1220 t = xs_dict_append(t, "href", a);
1221 t = xs_dict_append(t, "name", handle);
1222
1223 tag = xs_list_append(tag, t);
1224 }
1225 }
1219 } 1226 }
1220 1227
1221 /* get the context, if there is one */ 1228 /* get the context, if there is one */