mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 01:25:04 +00:00
Also import lists.csv.
This commit is contained in:
parent
56d5de2e41
commit
30323616cb
2 changed files with 23 additions and 0 deletions
3
data.c
3
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;
|
||||
}
|
||||
}
|
||||
|
|
20
utils.c
20
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue