commit 106791f

default  ·  2023-08-06 17:04:30 +0000 UTC
parent 28adb6c
Added command-line interface for limit/unlimit users.
2 files changed,  +31, -1
M main.c
+1, -1
1@@ -1570,7 +1570,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
2             snac_log(snac, xs_fmt("dropped 'Announce' from limited actor %s", actor));
3         else
4         if (valid_status(object_get(object, &a_msg))) {
5-            char *who = xs_dict_get(a_msg, "attributedTo");
6+            const char *who = xs_dict_get(a_msg, "attributedTo");
7 
8             if (who && !is_muted(snac, who)) {
9                 /* bring the actor */
M main.c
+30, -0
 1@@ -35,6 +35,8 @@ int usage(void)
 2     printf("unpin {basedir} {uid} {msg_url}     Unpins a message\n");
 3     printf("block {basedir} {instance_url}      Blocks a full instance\n");
 4     printf("unblock {basedir} {instance_url}    Unblocks a full instance\n");
 5+    printf("limit {basedir} {uid} {actor}       Limits an actor (drops their announces)\n");
 6+    printf("unlimit {basedir} {uid} {actor}     Unlimits an actor\n");
 7 
 8 /*    printf("question {basedir} {uid} 'opts'  Generates a poll (;-separated opts)\n");*/
 9 
10@@ -272,6 +274,34 @@ int main(int argc, char *argv[])
11         return 0;
12     }
13 
14+    if (strcmp(cmd, "limit") == 0) { /** **/
15+        int ret;
16+
17+        if (!following_check(&snac, url))
18+            snac_log(&snac, xs_fmt("actor %s is not being followed", url));
19+        else
20+        if ((ret = limit(&snac, url)) == 0)
21+            snac_log(&snac, xs_fmt("actor %s is now limited", url));
22+        else
23+            snac_log(&snac, xs_fmt("error limiting actor %s (%d)", url, ret));
24+
25+        return 0;
26+    }
27+
28+    if (strcmp(cmd, "unlimit") == 0) { /** **/
29+        int ret;
30+
31+        if (!following_check(&snac, url))
32+            snac_log(&snac, xs_fmt("actor %s is not being followed", url));
33+        else
34+        if ((ret = unlimit(&snac, url)) == 0)
35+            snac_log(&snac, xs_fmt("actor %s is no longer limited", url));
36+        else
37+            snac_log(&snac, xs_fmt("error unlimiting actor %s (%d)", url, ret));
38+
39+        return 0;
40+    }
41+
42     if (strcmp(cmd, "ping") == 0) { /** **/
43         xs *actor_o = NULL;
44