summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-02-15 10:46:16 +0100
committerGravatar default2024-02-15 10:46:16 +0100
commit2afcb4b6ecafeb852abb2d0bb48d170b469a5a36 (patch)
treeeb702c2bebdef8977349384ad3da4c5d60221af1
parentRenamed validated_metadata to validated_links. (diff)
downloadsnac2-2afcb4b6ecafeb852abb2d0bb48d170b469a5a36.tar.gz
snac2-2afcb4b6ecafeb852abb2d0bb48d170b469a5a36.tar.xz
snac2-2afcb4b6ecafeb852abb2d0bb48d170b469a5a36.zip
mastoapi: fill the verified_at fields in mastoapi_account() for local users.
-rw-r--r--mastoapi.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index e2c1ad6..4b7122c 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -622,6 +622,22 @@ xs_dict *mastoapi_account(const xs_dict *actor)
622 p = xs_dict_get(actor, "attachment"); 622 p = xs_dict_get(actor, "attachment");
623 xs_dict *v; 623 xs_dict *v;
624 624
625 /* dict of validated links */
626 xs_dict *val_links = NULL;
627
628 if (xs_startswith(id, srv_baseurl)) {
629 /* if it's a local user, open it and pick its validated links */
630 snac user;
631
632 if (user_open(&user, prefu)) {
633 val_links = xs_dict_get(user.config, "validated_links");
634 user_free(&user);
635 }
636 }
637
638 if (xs_is_null(val_links))
639 val_links = xs_stock_dict;
640
625 while (xs_list_iter(&p, &v)) { 641 while (xs_list_iter(&p, &v)) {
626 char *type = xs_dict_get(v, "type"); 642 char *type = xs_dict_get(v, "type");
627 char *name = xs_dict_get(v, "name"); 643 char *name = xs_dict_get(v, "name");
@@ -629,11 +645,18 @@ xs_dict *mastoapi_account(const xs_dict *actor)
629 645
630 if (!xs_is_null(type) && !xs_is_null(name) && 646 if (!xs_is_null(type) && !xs_is_null(name) &&
631 !xs_is_null(value) && strcmp(type, "PropertyValue") == 0) { 647 !xs_is_null(value) && strcmp(type, "PropertyValue") == 0) {
648 char *val_date = NULL;
649
650 if (xs_startswith(value, "https:/" "/"))
651 val_date = xs_dict_get(val_links, value);
652
632 xs *d = xs_dict_new(); 653 xs *d = xs_dict_new();
633 654
634 d = xs_dict_append(d, "name", name); 655 d = xs_dict_append(d, "name", name);
635 d = xs_dict_append(d, "value", value); 656 d = xs_dict_append(d, "value", value);
636 d = xs_dict_append(d, "verified_at", xs_stock_null); 657 d = xs_dict_append(d, "verified_at",
658 xs_type(val_date) == XSTYPE_STRING && *val_date ?
659 val_date : xs_stock_null);
637 660
638 fields = xs_list_append(fields, d); 661 fields = xs_list_append(fields, d);
639 } 662 }
@@ -1149,7 +1172,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1149 d = xs_dict_append(d, "name", k); 1172 d = xs_dict_append(d, "name", k);
1150 d = xs_dict_append(d, "value", v); 1173 d = xs_dict_append(d, "value", v);
1151 d = xs_dict_append(d, "verified_at", 1174 d = xs_dict_append(d, "verified_at",
1152 xs_type(val_date) == XSTYPE_STRING ? val_date : xs_stock_null); 1175 xs_type(val_date) == XSTYPE_STRING && *val_date ?
1176 val_date : xs_stock_null);
1153 1177
1154 fields = xs_list_append(fields, d); 1178 fields = xs_list_append(fields, d);
1155 } 1179 }