commit 057827e

default  ·  2023-06-29 06:11:41 +0000 UTC
parent 61957a8
Added command-line interface for [un]blocking full instances.
1 files changed,  +25, -0
M main.c
M main.c
+25, -0
 1@@ -33,6 +33,9 @@ int usage(void)
 2     printf("webfinger_s {basedir} {uid} {actor} Queries about an actor (@user@host or actor url)\n");
 3     printf("pin {basedir} {uid} {msg_url}       Pins a message\n");
 4     printf("unpin {basedir} {uid} {msg_url}     Unpins a message\n");
 5+    printf("block {basedir} {instance_url}      Blocks a full instance\n");
 6+    printf("unblock {basedir} {instance_url}    Unblocks a full instance\n");
 7+
 8 /*    printf("question {basedir} {uid} 'opts'  Generates a poll (;-separated opts)\n");*/
 9 
10     return 1;
11@@ -127,6 +130,28 @@ int main(int argc, char *argv[])
12     if ((user = GET_ARGV()) == NULL)
13         return usage();
14 
15+    if (strcmp(cmd, "block") == 0) { /** **/
16+        int ret = instance_block(user);
17+
18+        if (ret < 0) {
19+            fprintf(stderr, "Error blocking instance %s: %d\n", user, ret);
20+            return 1;
21+        }
22+
23+        return 0;
24+    }
25+
26+    if (strcmp(cmd, "unblock") == 0) { /** **/
27+        int ret = instance_unblock(user);
28+
29+        if (ret < 0) {
30+            fprintf(stderr, "Error unblocking instance %s: %d\n", user, ret);
31+            return 1;
32+        }
33+
34+        return 0;
35+    }
36+
37     if (strcmp(cmd, "webfinger") == 0) { /** **/
38         xs *actor = NULL;
39         xs *uid = NULL;