From 85ed0eb0d535700a5df837c37f51848811e461a0 Mon Sep 17 00:00:00 2001 From: violette Date: Thu, 18 Dec 2025 07:58:24 +0100 Subject: Added emoji reactions (contributed by violette). --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 6915bd0..4b0463e 100644 --- a/main.c +++ b/main.c @@ -498,7 +498,7 @@ int main(int argc, char *argv[]) if (msg != NULL) { enqueue_message(&snac, msg); - timeline_admire(&snac, xs_dict_get(msg, "object"), snac.actor, 0); + timeline_admire(&snac, xs_dict_get(msg, "object"), snac.actor, 0, ""); if (dbglevel) { xs_json_dump(msg, 4, stdout); -- cgit From 11af00194e3e0ec15e17a23556dc2929f92e0210 Mon Sep 17 00:00:00 2001 From: grunfink Date: Thu, 1 Jan 2026 17:01:03 +0100 Subject: Bumped copyright year. --- LICENSE | 2 +- activitypub.c | 2 +- data.c | 2 +- format.c | 2 +- html.c | 2 +- http.c | 2 +- httpd.c | 2 +- main.c | 4 ++-- mastoapi.c | 2 +- rss.c | 2 +- snac.c | 2 +- snac.h | 2 +- upgrade.c | 2 +- utils.c | 2 +- webfinger.c | 2 +- xs.h | 2 +- xs_curl.h | 2 +- xs_fcgi.h | 2 +- xs_glob.h | 2 +- xs_hex.h | 2 +- xs_html.h | 2 +- xs_http.h | 2 +- xs_httpd.h | 2 +- xs_io.h | 2 +- xs_json.h | 4 +++- xs_match.h | 2 +- xs_mime.h | 2 +- xs_openssl.h | 2 +- xs_po.h | 2 +- xs_random.h | 2 +- xs_regex.h | 2 +- xs_set.h | 2 +- xs_socket.h | 2 +- xs_time.h | 2 +- xs_unicode.h | 2 +- xs_unix_socket.h | 2 +- xs_url.h | 2 +- xs_version.h | 2 +- xs_webmention.h | 2 +- 39 files changed, 42 insertions(+), 40 deletions(-) (limited to 'main.c') diff --git a/LICENSE b/LICENSE index 702b487..3fa58d1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 - 2025 grunfink et al. (Fediverse: @grunfink@comam.es) +Copyright (c) 2022 - 2026 grunfink et al. (Fediverse: @grunfink@comam.es) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/activitypub.c b/activitypub.c index 59df31a..617fd30 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_json.h" diff --git a/data.c b/data.c index 023bae6..22ea7b0 100644 --- a/data.c +++ b/data.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_hex.h" diff --git a/format.c b/format.c index 4f93b7b..803e5a5 100644 --- a/format.c +++ b/format.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_regex.h" diff --git a/html.c b/html.c index 3e1d7ba..ef8816d 100644 --- a/html.c +++ b/html.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/http.c b/http.c index f0b1314..4f0b2fa 100644 --- a/http.c +++ b/http.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/httpd.c b/httpd.c index f93f197..f46cfca 100644 --- a/httpd.c +++ b/httpd.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/main.c b/main.c index 4b0463e..29a8a51 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_io.h" @@ -18,7 +18,7 @@ int usage(const char *cmd) { printf("snac " VERSION " - A simple, minimalistic ActivityPub instance\n"); - printf("Copyright (c) 2022 - 2025 grunfink et al. / MIT license\n"); + printf("Copyright (c) 2022 - 2026 grunfink et al. / MIT license\n"); printf("\n"); if (cmd == NULL) { diff --git a/mastoapi.c b/mastoapi.c index 6a12ced..0cadf2c 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef NO_MASTODON_API diff --git a/rss.c b/rss.c index 09446dc..dc26071 100644 --- a/rss.c +++ b/rss.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2025 grunfink et al. / MIT license */ +/* copyright (c) 2025 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_html.h" diff --git a/snac.c b/snac.c index 31f524f..965edbb 100644 --- a/snac.c +++ b/snac.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #define XS_IMPLEMENTATION diff --git a/snac.h b/snac.h index bcff7f8..430b551 100644 --- a/snac.h +++ b/snac.h @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #define VERSION "2.86-dev" diff --git a/upgrade.c b/upgrade.c index 9e0ae6e..07e9c51 100644 --- a/upgrade.c +++ b/upgrade.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/utils.c b/utils.c index 44e4006..4bdbaaf 100644 --- a/utils.c +++ b/utils.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_io.h" diff --git a/webfinger.c b/webfinger.c index 1ce5e76..264cb85 100644 --- a/webfinger.c +++ b/webfinger.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #include "xs.h" #include "xs_json.h" diff --git a/xs.h b/xs.h index 5f2e6aa..11f0722 100644 --- a/xs.h +++ b/xs.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_H diff --git a/xs_curl.h b/xs_curl.h index feb23e0..4b510ac 100644 --- a/xs_curl.h +++ b/xs_curl.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_CURL_H diff --git a/xs_fcgi.h b/xs_fcgi.h index b3cb892..0af6fcc 100644 --- a/xs_fcgi.h +++ b/xs_fcgi.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ /* This is an intentionally-dead-simple FastCGI implementation; diff --git a/xs_glob.h b/xs_glob.h index 6d87ca1..c38ec9a 100644 --- a/xs_glob.h +++ b/xs_glob.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_GLOB_H diff --git a/xs_hex.h b/xs_hex.h index 2507d5d..91c528e 100644 --- a/xs_hex.h +++ b/xs_hex.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_HEX_H diff --git a/xs_html.h b/xs_html.h index 29886c6..ab77499 100644 --- a/xs_html.h +++ b/xs_html.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_HTML_H diff --git a/xs_http.h b/xs_http.h index f2fd296..b9b5f80 100644 --- a/xs_http.h +++ b/xs_http.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_HTTP_H diff --git a/xs_httpd.h b/xs_httpd.h index 9be51e6..4a4689c 100644 --- a/xs_httpd.h +++ b/xs_httpd.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_HTTPD_H diff --git a/xs_io.h b/xs_io.h index 9c5018e..9a03e5b 100644 --- a/xs_io.h +++ b/xs_io.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_IO_H diff --git a/xs_json.h b/xs_json.h index 07800fa..a9577ee 100644 --- a/xs_json.h +++ b/xs_json.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_JSON_H @@ -28,6 +28,8 @@ int xs_json_load_object(FILE *f, int maxdepth, xs_dict **d); /** IMPLEMENTATION **/ +#include "xs_unicode.h" + /** JSON dumps **/ static void _xs_json_dump_str(const char *data, FILE *f) diff --git a/xs_match.h b/xs_match.h index 76c1bf3..21830e8 100644 --- a/xs_match.h +++ b/xs_match.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_MATCH_H diff --git a/xs_mime.h b/xs_mime.h index 0146385..6709ec6 100644 --- a/xs_mime.h +++ b/xs_mime.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_MIME_H diff --git a/xs_openssl.h b/xs_openssl.h index f215bcc..64b59dd 100644 --- a/xs_openssl.h +++ b/xs_openssl.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_OPENSSL_H diff --git a/xs_po.h b/xs_po.h index c6feec9..c1ad2c9 100644 --- a/xs_po.h +++ b/xs_po.h @@ -1,4 +1,4 @@ -/* copyright (c) 2025 grunfink et al. / MIT license */ +/* copyright (c) 2025 - 2026 grunfink et al. / MIT license */ #ifndef _XS_PO_H diff --git a/xs_random.h b/xs_random.h index f936099..357f9cb 100644 --- a/xs_random.h +++ b/xs_random.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_RANDOM_H diff --git a/xs_regex.h b/xs_regex.h index 1e157d2..5ccefda 100644 --- a/xs_regex.h +++ b/xs_regex.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_REGEX_H diff --git a/xs_set.h b/xs_set.h index 8946e42..ae67cc7 100644 --- a/xs_set.h +++ b/xs_set.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_SET_H diff --git a/xs_socket.h b/xs_socket.h index 7bf5298..70bfe98 100644 --- a/xs_socket.h +++ b/xs_socket.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_SOCKET_H diff --git a/xs_time.h b/xs_time.h index 507d238..46b35a1 100644 --- a/xs_time.h +++ b/xs_time.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_TIME_H diff --git a/xs_unicode.h b/xs_unicode.h index 0b4de1c..7686dcd 100644 --- a/xs_unicode.h +++ b/xs_unicode.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_UNICODE_H diff --git a/xs_unix_socket.h b/xs_unix_socket.h index 462a5b3..1ef7d39 100644 --- a/xs_unix_socket.h +++ b/xs_unix_socket.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_UNIX_SOCKET_H diff --git a/xs_url.h b/xs_url.h index 222771f..56d6d9d 100644 --- a/xs_url.h +++ b/xs_url.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_URL_H diff --git a/xs_version.h b/xs_version.h index 34a7a45..598c72e 100644 --- a/xs_version.h +++ b/xs_version.h @@ -1 +1 @@ -/* 0a8b987d7bb945fe7844411727d03ac73f417455 2025-10-14T05:21:05+02:00 */ +/* ad74258be9b1585840a5366cdb4b6ef707c0e95a 2026-01-01T16:58:39+01:00 */ diff --git a/xs_webmention.h b/xs_webmention.h index f9578b4..035b3a6 100644 --- a/xs_webmention.h +++ b/xs_webmention.h @@ -1,4 +1,4 @@ -/* copyright (c) 2025 grunfink et al. / MIT license */ +/* copyright (c) 2025 - 2026 grunfink et al. / MIT license */ #ifndef _XS_WEBMENTION_H -- cgit From 99375a7b664750c1288558f1d5c02b833a2e083c Mon Sep 17 00:00:00 2001 From: grunfink Date: Sat, 10 Jan 2026 21:29:32 +0100 Subject: New command-line option top_ten. --- Makefile | 8 +++---- Makefile.NetBSD | 8 +++---- main.c | 21 ++++++++++++++++- snac.h | 2 ++ utils.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 9 deletions(-) (limited to 'main.c') diff --git a/Makefile b/Makefile index ffeac1a..5614388 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ update-po: xgettext --omit-header -j -o $$a --language=C --keyword=L --from-code=utf-8 *.c ; \ done -activitypub.o: activitypub.c xs.h xs_json.h xs_curl.h xs_mime.h \ +activitypub.o: activitypub.c xs.h xs_json.h xs_curl.h xs_url.h xs_mime.h \ xs_openssl.h xs_regex.h xs_time.h xs_set.h xs_match.h xs_unicode.h \ xs_webmention.h xs_http.h xs_http_codes.h snac.h data.o: data.c xs.h xs_hex.h xs_io.h xs_json.h xs_openssl.h xs_glob.h \ @@ -68,16 +68,16 @@ mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \ xs_unicode.h xs_http.h xs_http_codes.h snac.h rss.o: rss.c xs.h xs_html.h xs_regex.h xs_time.h xs_match.h xs_curl.h \ - xs_openssl.h xs_json.h xs_http.h xs_http_codes.h snac.h + xs_openssl.h xs_json.h xs_http.h xs_http_codes.h xs_unicode.h snac.h sandbox.o: sandbox.c xs.h snac.h snac.o: snac.c xs.h xs_hex.h xs_io.h xs_unicode_tbl.h xs_unicode.h \ xs_json.h xs_curl.h xs_openssl.h xs_socket.h xs_unix_socket.h xs_url.h \ xs_http.h xs_http_codes.h xs_httpd.h xs_mime.h xs_regex.h xs_set.h \ xs_time.h xs_glob.h xs_random.h xs_match.h xs_fcgi.h xs_html.h xs_po.h \ - xs_webmention.h snac.h + xs_webmention.h xs_list_tools.h snac.h upgrade.o: upgrade.c xs.h xs_io.h xs_json.h xs_glob.h snac.h utils.o: utils.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h \ xs_random.h xs_glob.h xs_curl.h xs_regex.h xs_http.h xs_http_codes.h \ - snac.h + xs_list_tools.h xs_set.h snac.h webfinger.o: webfinger.c xs.h xs_json.h xs_curl.h xs_mime.h xs_http.h \ xs_http_codes.h snac.h diff --git a/Makefile.NetBSD b/Makefile.NetBSD index b5005ee..e752910 100644 --- a/Makefile.NetBSD +++ b/Makefile.NetBSD @@ -35,7 +35,7 @@ uninstall: rm $(PREFIX_MAN)/man5/snac.5 rm $(PREFIX_MAN)/man8/snac.8 -activitypub.o: activitypub.c xs.h xs_json.h xs_curl.h xs_mime.h \ +activitypub.o: activitypub.c xs.h xs_json.h xs_curl.h xs_url.h xs_mime.h \ xs_openssl.h xs_regex.h xs_time.h xs_set.h xs_match.h xs_unicode.h \ xs_webmention.h xs_http.h xs_http_codes.h snac.h data.o: data.c xs.h xs_hex.h xs_io.h xs_json.h xs_openssl.h xs_glob.h \ @@ -57,16 +57,16 @@ mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \ xs_unicode.h xs_http.h xs_http_codes.h snac.h rss.o: rss.c xs.h xs_html.h xs_regex.h xs_time.h xs_match.h xs_curl.h \ - xs_openssl.h xs_json.h xs_http.h xs_http_codes.h snac.h + xs_openssl.h xs_json.h xs_http.h xs_http_codes.h xs_unicode.h snac.h sandbox.o: sandbox.c xs.h snac.h snac.o: snac.c xs.h xs_hex.h xs_io.h xs_unicode_tbl.h xs_unicode.h \ xs_json.h xs_curl.h xs_openssl.h xs_socket.h xs_unix_socket.h xs_url.h \ xs_http.h xs_http_codes.h xs_httpd.h xs_mime.h xs_regex.h xs_set.h \ xs_time.h xs_glob.h xs_random.h xs_match.h xs_fcgi.h xs_html.h xs_po.h \ - xs_webmention.h snac.h + xs_webmention.h xs_list_tools.h snac.h upgrade.o: upgrade.c xs.h xs_io.h xs_json.h xs_glob.h snac.h utils.o: utils.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h \ xs_random.h xs_glob.h xs_curl.h xs_regex.h xs_http.h xs_http_codes.h \ - snac.h + xs_list_tools.h xs_set.h snac.h webfinger.o: webfinger.c xs.h xs_json.h xs_curl.h xs_mime.h xs_http.h \ xs_http_codes.h snac.h diff --git a/main.c b/main.c index 29a8a51..4ba9796 100644 --- a/main.c +++ b/main.c @@ -76,7 +76,8 @@ int usage(const char *cmd) "list_create {basedir} {uid} {name} Creates a new list\n" "list_remove {basedir} {uid} {name} Removes an existing list\n" "list_add {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n" - "list_del {basedir} {uid} {name} {actor} Deletes an actor URL from a list\n"; + "list_del {basedir} {uid} {name} {actor} Deletes an actor URL from a list\n" + "top_ten {basedir} {uid} [{N}] Prints the most popular posts\n"; if (cmd == NULL) printf("%s", cmds); @@ -350,6 +351,24 @@ int main(int argc, char *argv[]) return 0; } + if (strcmp(cmd, "top_ten") == 0) { /** **/ + int count = 10; + const char *n = GET_ARGV(); + if (xs_is_string(n)) + count = atoi(n); + + xs *l = user_top_ten(&snac, count); + const xs_list *i; + + xs_list_foreach(l, i) { + printf("%s %ld★ %ld↺\n", xs_list_get(i, 0), + xs_number_get_l(xs_list_get(i, 1)), + xs_number_get_l(xs_list_get(i, 2))); + } + + return 0; + } + if ((url = GET_ARGV()) == NULL) return usage(cmd); diff --git a/snac.h b/snac.h index 2364f72..e5efc0b 100644 --- a/snac.h +++ b/snac.h @@ -494,3 +494,5 @@ void rss_to_timeline(snac *user, const char *url); void rss_poll_hashtags(void); void data_fsck(void); + +xs_list *user_top_ten(snac *user, int count); diff --git a/utils.c b/utils.c index 4bdbaaf..fd077f6 100644 --- a/utils.c +++ b/utils.c @@ -11,6 +11,8 @@ #include "xs_curl.h" #include "xs_regex.h" #include "xs_http.h" +#include "xs_list_tools.h" +#include "xs_set.h" #include "snac.h" @@ -1002,6 +1004,76 @@ void import_csv(snac *user) snac_log(user, xs_fmt("Cannot open file %s", fn)); } + +static int top_ten_sort(const void *v1, const void *v2) +{ + const xs_list *l1 = *(const xs_list **)v1; + const xs_list *l2 = *(const xs_list **)v2; + + const char *c1 = xs_list_get(l1, 3); + const char *c2 = xs_list_get(l2, 3); + + return xs_cmp(c2, c1); +} + + +xs_list *user_top_ten(snac *user, int count) +/* returns the top ten more popular posts by a user */ +{ + xs *idx = xs_fmt("%s/private.idx", user->basedir); + xs *list = index_list(idx, XS_ALL); + xs *u_list = xs_list_new(); + xs_set u; + + xs_set_init(&u); + + const char *md5; + + xs_list_foreach(list, md5) { + xs *obj = NULL; + + if (!valid_status(object_get_by_md5(md5, &obj))) + continue; + + const char *id = xs_dict_get_def(obj, "id", "-"); + + if (!is_msg_mine(user, id)) + continue; + + if (xs_set_add(&u, id) != 1) + continue; + + /* get metrics */ + int ls = object_likes_len(id); + int as = object_announces_len(id); + + /* build the entry and convert to list */ + xs *s = xs_fmt("%s\t%d\t%d\t%010d", id, ls, as, ls + as); + xs *l = xs_split(s, "\t"); + + u_list = xs_list_append(u_list, l); + } + + /* sort by the sum of likes and boosts */ + xs *s_list = xs_list_sort(u_list, top_ten_sort); + + xs_list *r = xs_list_new(); + const xs_list *i; + + xs_list_foreach(s_list, i) { + r = xs_list_append(r, i); + + if (--count <= 0) + break; + } + + xs_set_free(&u); + + return r; +} + + + static const struct { const char *proto; unsigned short default_port; -- cgit From d8d40acfd17dfe28654f7acfac648a896033b63b Mon Sep 17 00:00:00 2001 From: grunfink Date: Mon, 19 Jan 2026 15:53:19 +0100 Subject: New command-line option 'refresh'. --- activitypub.c | 2 +- main.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/activitypub.c b/activitypub.c index 1992b13..c34e510 100644 --- a/activitypub.c +++ b/activitypub.c @@ -3395,7 +3395,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item) actor_add(actor, actor_o); } else { - if (status == HTTP_STATUS_GONE) { + if (status == HTTP_STATUS_GONE || status == HTTP_STATUS_NOT_FOUND) { actor_failure(actor, 1); snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status)); } diff --git a/main.c b/main.c index 4ba9796..e7d5b0d 100644 --- a/main.c +++ b/main.c @@ -77,7 +77,8 @@ int usage(const char *cmd) "list_remove {basedir} {uid} {name} Removes an existing list\n" "list_add {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n" "list_del {basedir} {uid} {name} {actor} Deletes an actor URL from a list\n" - "top_ten {basedir} {uid} [{N}] Prints the most popular posts\n"; + "top_ten {basedir} {uid} [{N}] Prints the most popular posts\n" + "refresh {basedir} {uid} Refreshes all actors\n"; if (cmd == NULL) printf("%s", cmds); @@ -369,6 +370,20 @@ int main(int argc, char *argv[]) return 0; } + if (strcmp(cmd, "refresh") == 0) { /** **/ + xs *fwers = follower_list(&snac); + xs *fwing = following_list(&snac); + const char *id; + + xs_list_foreach(fwers, id) + enqueue_actor_refresh(&snac, id, 0); + + xs_list_foreach(fwing, id) + enqueue_actor_refresh(&snac, id, 0); + + return 0; + } + if ((url = GET_ARGV()) == NULL) return usage(cmd); -- cgit