From 30323616cb2f34d177a079189a6763cd43c050d6 Mon Sep 17 00:00:00 2001 From: default Date: Sat, 19 Oct 2024 21:22:52 +0200 Subject: [PATCH] Also import lists.csv. --- data.c | 3 +++ utils.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/data.c b/data.c index 1448bab..00494a2 100644 --- a/data.c +++ b/data.c @@ -2004,6 +2004,9 @@ xs_val *list_maint(snac *user, const char *list, int op) while (xs_list_next(lol, &v, &c)) { if (strcmp(xs_list_get(v, 1), list) == 0) { add = 0; + + l = xs_dup(xs_list_get(v, 0)); + break; } } diff --git a/utils.c b/utils.c index e6d14d0..4f5ac55 100644 --- a/utils.c +++ b/utils.c @@ -766,6 +766,26 @@ void import_csv(snac *user) xs *l = xs_strip_i(xs_readline(f)); if (*l) { + xs *l2 = xs_split(l, ","); + const char *lname = xs_list_get(l2, 0); + const char *acct = xs_list_get(l2, 1); + + if (lname && acct) { + /* create the list */ + xs *list_id = list_maint(user, lname, 1); + + xs *url = NULL; + xs *uid = NULL; + + if (valid_status(webfinger_request(acct, &url, &uid))) { + xs *actor_md5 = xs_md5_hex(url, strlen(url)); + + list_content(user, list_id, actor_md5, 1); + snac_log(user, xs_fmt("Added %s to list %s", url, lname)); + } + else + snac_log(user, xs_fmt("Webfinger error while adding %s to list %s", acct, lname)); + } } }