summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-08-06 19:04:30 +0200
committerGravatar default2023-08-06 19:04:30 +0200
commit106791ff6ba11c256b42a69c1ff052da3e8413fe (patch)
tree7e06feb4704ac0bdd65640729e923a67621d9aaf
parentDrop announces from limited users. (diff)
downloadsnac2-106791ff6ba11c256b42a69c1ff052da3e8413fe.tar.gz
snac2-106791ff6ba11c256b42a69c1ff052da3e8413fe.tar.xz
snac2-106791ff6ba11c256b42a69c1ff052da3e8413fe.zip
Added command-line interface for limit/unlimit users.
-rw-r--r--activitypub.c2
-rw-r--r--main.c30
2 files changed, 31 insertions, 1 deletions
diff --git a/activitypub.c b/activitypub.c
index dc9ec95..194511e 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1570,7 +1570,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1570 snac_log(snac, xs_fmt("dropped 'Announce' from limited actor %s", actor)); 1570 snac_log(snac, xs_fmt("dropped 'Announce' from limited actor %s", actor));
1571 else 1571 else
1572 if (valid_status(object_get(object, &a_msg))) { 1572 if (valid_status(object_get(object, &a_msg))) {
1573 char *who = xs_dict_get(a_msg, "attributedTo"); 1573 const char *who = xs_dict_get(a_msg, "attributedTo");
1574 1574
1575 if (who && !is_muted(snac, who)) { 1575 if (who && !is_muted(snac, who)) {
1576 /* bring the actor */ 1576 /* bring the actor */
diff --git a/main.c b/main.c
index 62f5041..bea6628 100644
--- a/main.c
+++ b/main.c
@@ -35,6 +35,8 @@ int usage(void)
35 printf("unpin {basedir} {uid} {msg_url} Unpins a message\n"); 35 printf("unpin {basedir} {uid} {msg_url} Unpins a message\n");
36 printf("block {basedir} {instance_url} Blocks a full instance\n"); 36 printf("block {basedir} {instance_url} Blocks a full instance\n");
37 printf("unblock {basedir} {instance_url} Unblocks a full instance\n"); 37 printf("unblock {basedir} {instance_url} Unblocks a full instance\n");
38 printf("limit {basedir} {uid} {actor} Limits an actor (drops their announces)\n");
39 printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n");
38 40
39/* printf("question {basedir} {uid} 'opts' Generates a poll (;-separated opts)\n");*/ 41/* printf("question {basedir} {uid} 'opts' Generates a poll (;-separated opts)\n");*/
40 42
@@ -272,6 +274,34 @@ int main(int argc, char *argv[])
272 return 0; 274 return 0;
273 } 275 }
274 276
277 if (strcmp(cmd, "limit") == 0) { /** **/
278 int ret;
279
280 if (!following_check(&snac, url))
281 snac_log(&snac, xs_fmt("actor %s is not being followed", url));
282 else
283 if ((ret = limit(&snac, url)) == 0)
284 snac_log(&snac, xs_fmt("actor %s is now limited", url));
285 else
286 snac_log(&snac, xs_fmt("error limiting actor %s (%d)", url, ret));
287
288 return 0;
289 }
290
291 if (strcmp(cmd, "unlimit") == 0) { /** **/
292 int ret;
293
294 if (!following_check(&snac, url))
295 snac_log(&snac, xs_fmt("actor %s is not being followed", url));
296 else
297 if ((ret = unlimit(&snac, url)) == 0)
298 snac_log(&snac, xs_fmt("actor %s is no longer limited", url));
299 else
300 snac_log(&snac, xs_fmt("error unlimiting actor %s (%d)", url, ret));
301
302 return 0;
303 }
304
275 if (strcmp(cmd, "ping") == 0) { /** **/ 305 if (strcmp(cmd, "ping") == 0) { /** **/
276 xs *actor_o = NULL; 306 xs *actor_o = NULL;
277 307