diff options
| author | 2022-10-06 19:06:05 +0200 | |
|---|---|---|
| committer | 2022-10-06 19:06:05 +0200 | |
| commit | 6befe9e569b70f3765534c17b1f67e459b0eb1fa (patch) | |
| tree | 78065fc2903520cd648a247d1605c0898da01125 | |
| parent | Updated TODO. (diff) | |
| download | snac2-6befe9e569b70f3765534c17b1f67e459b0eb1fa.tar.gz snac2-6befe9e569b70f3765534c17b1f67e459b0eb1fa.tar.xz snac2-6befe9e569b70f3765534c17b1f67e459b0eb1fa.zip | |
New function build_mentions(), for the reply textareas.
| -rw-r--r-- | html.c | 41 |
1 files changed, 40 insertions, 1 deletions
| @@ -390,6 +390,45 @@ d_char *html_button(d_char *s, char *clss, char *label) | |||
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | 392 | ||
| 393 | d_char *build_mentions(snac *snac, char *msg) | ||
| 394 | /* returns a string with the mentions in msg */ | ||
| 395 | { | ||
| 396 | d_char *s = xs_str_new(NULL); | ||
| 397 | char *list = xs_dict_get(msg, "tag"); | ||
| 398 | char *v; | ||
| 399 | |||
| 400 | while (xs_list_iter(&list, &v)) { | ||
| 401 | char *type = xs_dict_get(v, "type"); | ||
| 402 | char *href = xs_dict_get(v, "href"); | ||
| 403 | char *name = xs_dict_get(v, "name"); | ||
| 404 | |||
| 405 | if (type && strcmp(type, "Mention") == 0 && | ||
| 406 | href && strcmp(href, snac->actor) != 0 && name) { | ||
| 407 | xs *l = xs_split(name, "@"); | ||
| 408 | |||
| 409 | /* if it's a name without host, query the webfinger */ | ||
| 410 | if (xs_list_len(l) < 3) { | ||
| 411 | #if 0 | ||
| 412 | xs *actor = NULL; | ||
| 413 | xs *user = NULL; | ||
| 414 | |||
| 415 | if (valid_status(webfinger_request(href, &actor, &user))) { | ||
| 416 | s = xs_str_cat(s, user); | ||
| 417 | s = xs_str_cat(s, " "); | ||
| 418 | } | ||
| 419 | #endif | ||
| 420 | } | ||
| 421 | else { | ||
| 422 | s = xs_str_cat(s, name); | ||
| 423 | s = xs_str_cat(s, " "); | ||
| 424 | } | ||
| 425 | } | ||
| 426 | } | ||
| 427 | |||
| 428 | return s; | ||
| 429 | } | ||
| 430 | |||
| 431 | |||
| 393 | d_char *html_entry_controls(snac *snac, d_char *os, char *msg) | 432 | d_char *html_entry_controls(snac *snac, d_char *os, char *msg) |
| 394 | { | 433 | { |
| 395 | char *id = xs_dict_get(msg, "id"); | 434 | char *id = xs_dict_get(msg, "id"); |
| @@ -453,7 +492,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg) | |||
| 453 | 492 | ||
| 454 | { | 493 | { |
| 455 | /* the post textarea */ | 494 | /* the post textarea */ |
| 456 | xs *ct = xs_str_new(""); | 495 | xs *ct = build_mentions(snac, msg); |
| 457 | 496 | ||
| 458 | xs *s1 = xs_fmt( | 497 | xs *s1 = xs_fmt( |
| 459 | "<p><div class=\"snac-note\" style=\"display: none\" id=\"%s_reply\">\n" | 498 | "<p><div class=\"snac-note\" style=\"display: none\" id=\"%s_reply\">\n" |