diff options
author | default <nobody@localhost> | 2022-09-27 18:33:25 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-09-27 18:33:25 +0200 |
commit | 66a7f633b3b48d0d5652fb6c2af23badf379a4cb (patch) | |
tree | 661ef40d3b17f3133315a4970c22b062f535a892 | |
parent | b6c4906c6af96ca3847cc716f3c3174bbc0085b4 (diff) |
Call process_tags() from msg_note().
-rw-r--r-- | activitypub.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/activitypub.c b/activitypub.c index 47e9efe..025c48c 100644 --- a/activitypub.c +++ b/activitypub.c @@ -212,7 +212,7 @@ void process_tags(const char *content, d_char **n_content, d_char **tag) char *p, *v; int n = 0; - p = split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9-\\.]+|#[^ ]+)"); + p = split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)"); while (xs_list_iter(&p, &v)) { if ((n & 0x1)) { if (*v == '@') { @@ -221,16 +221,21 @@ void process_tags(const char *content, d_char **n_content, d_char **tag) xs *uid = NULL; int status; - status = webfinger_request(v, &actor, &uid); + status = webfinger_request(v + 1, &actor, &uid); if (valid_status(status)) { xs *d = xs_dict_new(); + xs *n = xs_fmt("@%s", uid); + xs *l = xs_fmt("<a href=\"%s\">%s</a>", actor, n); d = xs_dict_append(d, "type", "Mention"); d = xs_dict_append(d, "href", actor); - d = xs_dict_append(d, "name", uid); + d = xs_dict_append(d, "name", n); tl = xs_list_append(tl, d); + + /* add the code */ + nc = xs_str_cat(nc, l); } else /* store as is */ @@ -466,6 +471,7 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to) xs *ntid = tid(0); xs *id = xs_fmt("%s/p/%s", snac->actor, ntid); xs *ctxt = NULL; + xs *fc2 = NULL; xs *fc1 = NULL; xs *to = NULL; xs *cc = xs_list_new(); @@ -480,7 +486,10 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to) to = xs_dup(rcpts); /* format the content */ - not_really_markdown(content, &fc1); + not_really_markdown(content, &fc2); + + /* extract the tags */ + process_tags(fc2, &fc1, &tag); if (in_reply_to != NULL) { xs *p_msg = NULL; |