summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-11-25 10:24:47 +0100
committerGravatar default2024-11-25 10:24:47 +0100
commitb3be8e06734c6428376514024af7cabf13774dce (patch)
treef7e655e55c208270e729b9a0fec0ec22f8196282
parentMost CSV import code has been moved to their own functions. (diff)
downloadpenes-snac2-b3be8e06734c6428376514024af7cabf13774dce.tar.gz
penes-snac2-b3be8e06734c6428376514024af7cabf13774dce.tar.xz
penes-snac2-b3be8e06734c6428376514024af7cabf13774dce.zip
New cmdline ops 'import_list' and 'import_block_list'.
-rw-r--r--main.c14
-rw-r--r--utils.c2
2 files changed, 15 insertions, 1 deletions
diff --git a/main.c b/main.c
index c285fac..088d382 100644
--- a/main.c
+++ b/main.c
@@ -52,6 +52,8 @@ int usage(void)
52 printf("alias {basedir} {uid} {account} Sets account (@user@host or actor url) as an alias\n"); 52 printf("alias {basedir} {uid} {account} Sets account (@user@host or actor url) as an alias\n");
53 printf("migrate {basedir} {uid} Migrates to the account defined as the alias\n"); 53 printf("migrate {basedir} {uid} Migrates to the account defined as the alias\n");
54 printf("import_csv {basedir} {uid} Imports data from CSV files into current directory\n"); 54 printf("import_csv {basedir} {uid} Imports data from CSV files into current directory\n");
55 printf("import_list {basedir} {uid} {file} Imports a Mastodon CSV list file\n");
56 printf("import_block_list {basedir} {uid} {file} Imports a Mastodon CSV block list file\n");
55 57
56 return 1; 58 return 1;
57} 59}
@@ -589,6 +591,18 @@ int main(int argc, char *argv[])
589 return 0; 591 return 0;
590 } 592 }
591 593
594 if (strcmp(cmd, "import_list") == 0) { /** **/
595 import_list_csv(&snac, url);
596
597 return 0;
598 }
599
600 if (strcmp(cmd, "import_block_list") == 0) { /** **/
601 import_blocked_accounts_csv(&snac, url);
602
603 return 0;
604 }
605
592 if (strcmp(cmd, "note") == 0) { /** **/ 606 if (strcmp(cmd, "note") == 0) { /** **/
593 xs *content = NULL; 607 xs *content = NULL;
594 xs *msg = NULL; 608 xs *msg = NULL;
diff --git a/utils.c b/utils.c
index b0d8193..df3b55d 100644
--- a/utils.c
+++ b/utils.c
@@ -681,7 +681,7 @@ void import_blocked_accounts_csv(snac *user, const char *fn)
681 while (!feof(f)) { 681 while (!feof(f)) {
682 xs *l = xs_strip_i(xs_readline(f)); 682 xs *l = xs_strip_i(xs_readline(f));
683 683
684 if (*l) { 684 if (*l && strchr(l, '@') != NULL) {
685 xs *url = NULL; 685 xs *url = NULL;
686 xs *uid = NULL; 686 xs *uid = NULL;
687 687