summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/main.c b/main.c
index 6915bd0..e7d5b0d 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
1/* snac - A simple, minimalistic ActivityPub instance */ 1/* snac - A simple, minimalistic ActivityPub instance */
2/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ 2/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */
3 3
4#include "xs.h" 4#include "xs.h"
5#include "xs_io.h" 5#include "xs_io.h"
@@ -18,7 +18,7 @@
18int usage(const char *cmd) 18int usage(const char *cmd)
19{ 19{
20 printf("snac " VERSION " - A simple, minimalistic ActivityPub instance\n"); 20 printf("snac " VERSION " - A simple, minimalistic ActivityPub instance\n");
21 printf("Copyright (c) 2022 - 2025 grunfink et al. / MIT license\n"); 21 printf("Copyright (c) 2022 - 2026 grunfink et al. / MIT license\n");
22 printf("\n"); 22 printf("\n");
23 23
24 if (cmd == NULL) { 24 if (cmd == NULL) {
@@ -76,7 +76,9 @@ int usage(const char *cmd)
76 "list_create {basedir} {uid} {name} Creates a new list\n" 76 "list_create {basedir} {uid} {name} Creates a new list\n"
77 "list_remove {basedir} {uid} {name} Removes an existing list\n" 77 "list_remove {basedir} {uid} {name} Removes an existing list\n"
78 "list_add {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n" 78 "list_add {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n"
79 "list_del {basedir} {uid} {name} {actor} Deletes an actor URL from a list\n"; 79 "list_del {basedir} {uid} {name} {actor} Deletes an actor URL from a list\n"
80 "top_ten {basedir} {uid} [{N}] Prints the most popular posts\n"
81 "refresh {basedir} {uid} Refreshes all actors\n";
80 82
81 if (cmd == NULL) 83 if (cmd == NULL)
82 printf("%s", cmds); 84 printf("%s", cmds);
@@ -350,6 +352,38 @@ int main(int argc, char *argv[])
350 return 0; 352 return 0;
351 } 353 }
352 354
355 if (strcmp(cmd, "top_ten") == 0) { /** **/
356 int count = 10;
357 const char *n = GET_ARGV();
358 if (xs_is_string(n))
359 count = atoi(n);
360
361 xs *l = user_top_ten(&snac, count);
362 const xs_list *i;
363
364 xs_list_foreach(l, i) {
365 printf("%s %ld★ %ld↺\n", xs_list_get(i, 0),
366 xs_number_get_l(xs_list_get(i, 1)),
367 xs_number_get_l(xs_list_get(i, 2)));
368 }
369
370 return 0;
371 }
372
373 if (strcmp(cmd, "refresh") == 0) { /** **/
374 xs *fwers = follower_list(&snac);
375 xs *fwing = following_list(&snac);
376 const char *id;
377
378 xs_list_foreach(fwers, id)
379 enqueue_actor_refresh(&snac, id, 0);
380
381 xs_list_foreach(fwing, id)
382 enqueue_actor_refresh(&snac, id, 0);
383
384 return 0;
385 }
386
353 if ((url = GET_ARGV()) == NULL) 387 if ((url = GET_ARGV()) == NULL)
354 return usage(cmd); 388 return usage(cmd);
355 389
@@ -498,7 +532,7 @@ int main(int argc, char *argv[])
498 532
499 if (msg != NULL) { 533 if (msg != NULL) {
500 enqueue_message(&snac, msg); 534 enqueue_message(&snac, msg);
501 timeline_admire(&snac, xs_dict_get(msg, "object"), snac.actor, 0); 535 timeline_admire(&snac, xs_dict_get(msg, "object"), snac.actor, 0, "");
502 536
503 if (dbglevel) { 537 if (dbglevel) {
504 xs_json_dump(msg, 4, stdout); 538 xs_json_dump(msg, 4, stdout);