mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
Also export lists.csv.
This commit is contained in:
parent
748d60497f
commit
53f339abf6
1 changed files with 35 additions and 0 deletions
35
utils.c
35
utils.c
|
@ -618,6 +618,41 @@ void export_csv(snac *user)
|
|||
}
|
||||
else
|
||||
snac_log(user, xs_fmt("Cannot create file %s", fn));
|
||||
|
||||
fn = "lists.csv";
|
||||
if ((f = fopen(fn, "w")) != NULL) {
|
||||
snac_log(user, xs_fmt("Creating %s...", fn));
|
||||
|
||||
xs *lol = list_maint(user, NULL, 0);
|
||||
const xs_list *li;
|
||||
|
||||
xs_list_foreach(lol, li) {
|
||||
const char *lid = xs_list_get(li, 0);
|
||||
const char *ltitle = xs_list_get(li, 1);
|
||||
|
||||
xs *actors = list_content(user, lid, NULL, 0);
|
||||
const char *md5;
|
||||
|
||||
xs_list_foreach(actors, md5) {
|
||||
xs *actor = NULL;
|
||||
|
||||
if (valid_status(object_get_by_md5(md5, &actor))) {
|
||||
const char *id = xs_dict_get(actor, "id");
|
||||
xs *uid = NULL;
|
||||
int status;
|
||||
|
||||
if (valid_status((status = webfinger_request(id, NULL, &uid))))
|
||||
fprintf(f, "%s,%s\n", ltitle, uid);
|
||||
else
|
||||
snac_log(user, xs_fmt("Error resolving list member %s %d", id, status));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
snac_log(user, xs_fmt("Cannot create file %s", fn));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue