summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/html.c b/html.c
index 586d7d7..b011749 100644
--- a/html.c
+++ b/html.c
@@ -390,6 +390,45 @@ d_char *html_button(d_char *s, char *clss, char *label)
390} 390}
391 391
392 392
393d_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
393d_char *html_entry_controls(snac *snac, d_char *os, char *msg) 432d_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"