diff options
| author | 2022-09-27 18:33:25 +0200 | |
|---|---|---|
| committer | 2022-09-27 18:33:25 +0200 | |
| commit | 66a7f633b3b48d0d5652fb6c2af23badf379a4cb (patch) | |
| tree | 661ef40d3b17f3133315a4970c22b062f535a892 /activitypub.c | |
| parent | New function process_tags() (untested). (diff) | |
| download | snac2-66a7f633b3b48d0d5652fb6c2af23badf379a4cb.tar.gz snac2-66a7f633b3b48d0d5652fb6c2af23badf379a4cb.tar.xz snac2-66a7f633b3b48d0d5652fb6c2af23badf379a4cb.zip | |
Call process_tags() from msg_note().
Diffstat (limited to 'activitypub.c')
| -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) | |||
| 212 | char *p, *v; | 212 | char *p, *v; |
| 213 | int n = 0; | 213 | int n = 0; |
| 214 | 214 | ||
| 215 | p = split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9-\\.]+|#[^ ]+)"); | 215 | p = split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)"); |
| 216 | while (xs_list_iter(&p, &v)) { | 216 | while (xs_list_iter(&p, &v)) { |
| 217 | if ((n & 0x1)) { | 217 | if ((n & 0x1)) { |
| 218 | if (*v == '@') { | 218 | if (*v == '@') { |
| @@ -221,16 +221,21 @@ void process_tags(const char *content, d_char **n_content, d_char **tag) | |||
| 221 | xs *uid = NULL; | 221 | xs *uid = NULL; |
| 222 | int status; | 222 | int status; |
| 223 | 223 | ||
| 224 | status = webfinger_request(v, &actor, &uid); | 224 | status = webfinger_request(v + 1, &actor, &uid); |
| 225 | 225 | ||
| 226 | if (valid_status(status)) { | 226 | if (valid_status(status)) { |
| 227 | xs *d = xs_dict_new(); | 227 | xs *d = xs_dict_new(); |
| 228 | xs *n = xs_fmt("@%s", uid); | ||
| 229 | xs *l = xs_fmt("<a href=\"%s\">%s</a>", actor, n); | ||
| 228 | 230 | ||
| 229 | d = xs_dict_append(d, "type", "Mention"); | 231 | d = xs_dict_append(d, "type", "Mention"); |
| 230 | d = xs_dict_append(d, "href", actor); | 232 | d = xs_dict_append(d, "href", actor); |
| 231 | d = xs_dict_append(d, "name", uid); | 233 | d = xs_dict_append(d, "name", n); |
| 232 | 234 | ||
| 233 | tl = xs_list_append(tl, d); | 235 | tl = xs_list_append(tl, d); |
| 236 | |||
| 237 | /* add the code */ | ||
| 238 | nc = xs_str_cat(nc, l); | ||
| 234 | } | 239 | } |
| 235 | else | 240 | else |
| 236 | /* store as is */ | 241 | /* store as is */ |
| @@ -466,6 +471,7 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to) | |||
| 466 | xs *ntid = tid(0); | 471 | xs *ntid = tid(0); |
| 467 | xs *id = xs_fmt("%s/p/%s", snac->actor, ntid); | 472 | xs *id = xs_fmt("%s/p/%s", snac->actor, ntid); |
| 468 | xs *ctxt = NULL; | 473 | xs *ctxt = NULL; |
| 474 | xs *fc2 = NULL; | ||
| 469 | xs *fc1 = NULL; | 475 | xs *fc1 = NULL; |
| 470 | xs *to = NULL; | 476 | xs *to = NULL; |
| 471 | xs *cc = xs_list_new(); | 477 | xs *cc = xs_list_new(); |
| @@ -480,7 +486,10 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to) | |||
| 480 | to = xs_dup(rcpts); | 486 | to = xs_dup(rcpts); |
| 481 | 487 | ||
| 482 | /* format the content */ | 488 | /* format the content */ |
| 483 | not_really_markdown(content, &fc1); | 489 | not_really_markdown(content, &fc2); |
| 490 | |||
| 491 | /* extract the tags */ | ||
| 492 | process_tags(fc2, &fc1, &tag); | ||
| 484 | 493 | ||
| 485 | if (in_reply_to != NULL) { | 494 | if (in_reply_to != NULL) { |
| 486 | xs *p_msg = NULL; | 495 | xs *p_msg = NULL; |