From 932227bbac7fe740bff1e38bf92b58edef19e32f Mon Sep 17 00:00:00 2001 From: default Date: Wed, 8 Jan 2025 16:59:14 +0100 Subject: Bumped copyright year. --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 7d23c84..5b1dd61 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ /* snac - A simple, minimalistic ActivityPub instance */ -/* copyright (c) 2022 - 2024 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ #include "xs.h" #include "xs_io.h" @@ -14,7 +14,7 @@ int usage(void) { printf("snac " VERSION " - A simple, minimalistic ActivityPub instance\n"); - printf("Copyright (c) 2022 - 2024 grunfink et al. / MIT license\n"); + printf("Copyright (c) 2022 - 2025 grunfink et al. / MIT license\n"); printf("\n"); printf("Commands:\n"); printf("\n"); -- cgit v1.2.3 From ff44142b30ceded6ed7db24d033296b0966edb27 Mon Sep 17 00:00:00 2001 From: default Date: Sat, 11 Jan 2025 01:39:37 +0100 Subject: Moved creation of "quiet public" posts to msg_note(), where it belongs. --- main.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 5b1dd61..83b73af 100644 --- a/main.c +++ b/main.c @@ -668,15 +668,8 @@ int main(int argc, char *argv[]) else content = xs_dup(url); - msg = msg_note(&snac, content, NULL, NULL, attl, 0, getenv("LANG")); - - if (strcmp(cmd, "note_unlisted") == 0) { - /* according to Mastodon, "unlisted" posts (now called "quiet public") - has the public address as a cc instead of to, so toggle it */ - xs *to = xs_dup(xs_dict_get(msg, "to")); - msg = xs_dict_set(msg, "cc", to); - msg = xs_dict_set(msg, "to", xs_stock(XSTYPE_LIST)); - } + msg = msg_note(&snac, content, NULL, NULL, attl, + strcmp(cmd, "note_unlisted") == 0 ? 2 : 0, getenv("LANG")); c_msg = msg_create(&snac, msg); -- cgit v1.2.3 From f88a32dbe0805fceb3fb75b01de61616d7953f5e Mon Sep 17 00:00:00 2001 From: default Date: Sun, 12 Jan 2025 11:30:16 +0100 Subject: mastoapi: fixed Events not being shown. --- main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index 83b73af..b4e7fa1 100644 --- a/main.c +++ b/main.c @@ -351,6 +351,22 @@ int main(int argc, char *argv[]) return 0; } + + if (strcmp(cmd, "assist") == 0) { /** **/ + /* undocumented: experimental (do not use) */ + xs *msg = msg_admiration(&snac, url, "Accept"); + + if (msg != NULL) { + enqueue_message(&snac, msg); + + if (dbglevel) { + xs_json_dump(msg, 4, stdout); + } + } + + return 0; + } + if (strcmp(cmd, "unboost") == 0) { /** **/ xs *msg = msg_repulsion(&snac, url, "Announce"); -- cgit v1.2.3 From e42cf9b5c055dd0fb0a9de139f0273cf7e9d7084 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 19 Jan 2025 18:27:59 +0100 Subject: New command 'note_mention'. --- main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index b4e7fa1..6eefbf4 100644 --- a/main.c +++ b/main.c @@ -6,6 +6,7 @@ #include "xs_json.h" #include "xs_time.h" #include "xs_openssl.h" +#include "xs_match.h" #include "snac.h" @@ -34,6 +35,7 @@ int usage(void) printf("actor {basedir} [{uid}] {url} Requests an actor\n"); printf("note {basedir} {uid} {text} [files...] Sends a note with optional attachments\n"); printf("note_unlisted {basedir} {uid} {text} [files...] Sends an unlisted note with optional attachments\n"); + printf("note_mention {basedir} {uid} {text} [files...] Sends a note only to mentioned accounts\n"); printf("boost|announce {basedir} {uid} {url} Boosts (announces) a post\n"); printf("unboost {basedir} {uid} {url} Unboosts a post\n"); printf("resetpwd {basedir} {uid} Resets the password of a user\n"); @@ -620,7 +622,7 @@ int main(int argc, char *argv[]) return 0; } - if (strcmp(cmd, "note") == 0 || strcmp(cmd, "note_unlisted") == 0) { /** **/ + if (xs_match(cmd, "note|note_unlisted|note_mention")) { /** **/ xs *content = NULL; xs *msg = NULL; xs *c_msg = NULL; @@ -684,8 +686,14 @@ int main(int argc, char *argv[]) else content = xs_dup(url); - msg = msg_note(&snac, content, NULL, NULL, attl, - strcmp(cmd, "note_unlisted") == 0 ? 2 : 0, getenv("LANG")); + int scope = 0; + if (strcmp(cmd, "note_mention") == 0) + scope = 1; + else + if (strcmp(cmd, "note_unlisted") == 0) + scope = 2; + + msg = msg_note(&snac, content, NULL, NULL, attl, scope, getenv("LANG")); c_msg = msg_create(&snac, msg); -- cgit v1.2.3 From b3ca9a50e7fe365a7757d39b7a3c192827b0b680 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 19 Jan 2025 18:39:07 +0100 Subject: changed note* commands checking. --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 6eefbf4..5678af4 100644 --- a/main.c +++ b/main.c @@ -622,7 +622,9 @@ int main(int argc, char *argv[]) return 0; } - if (xs_match(cmd, "note|note_unlisted|note_mention")) { /** **/ + if (strcmp(cmd, "note") == 0 || /** **/ + strcmp(cmd, "note_unlisted") == 0 || /** **/ + strcmp(cmd, "note_mention") == 0) { /** **/ xs *content = NULL; xs *msg = NULL; xs *c_msg = NULL; -- cgit v1.2.3 From 5b21c9546b40cc0c52d5f39273747c551926984c Mon Sep 17 00:00:00 2001 From: default Date: Mon, 20 Jan 2025 10:40:43 +0100 Subject: Added support for the SNAC_BASEDIR environment variable. If it's set, the basedir argument in command-line commands must not be given. --- main.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 5678af4..db26252 100644 --- a/main.c +++ b/main.c @@ -96,19 +96,6 @@ int main(int argc, char *argv[]) return snac_init(basedir); } - if (strcmp(cmd, "upgrade") == 0) { /** **/ - int ret; - - /* upgrade */ - if ((basedir = GET_ARGV()) == NULL) - return usage(); - - if ((ret = srv_open(basedir, 1)) == 1) - srv_log(xs_dup("OK")); - - return ret; - } - if (strcmp(cmd, "markdown") == 0) { /** **/ /* undocumented, for testing only */ xs *c = xs_readall(stdin); @@ -118,8 +105,20 @@ int main(int argc, char *argv[]) return 0; } - if ((basedir = GET_ARGV()) == NULL) - return usage(); + if ((basedir = getenv("SNAC_BASEDIR")) == NULL) { + if ((basedir = GET_ARGV()) == NULL) + return usage(); + } + + if (strcmp(cmd, "upgrade") == 0) { /** **/ + int ret; + + /* upgrade */ + if ((ret = srv_open(basedir, 1)) == 1) + srv_log(xs_dup("OK")); + + return ret; + } if (!srv_open(basedir, 0)) { srv_log(xs_fmt("error opening data storage at %s", basedir)); -- cgit v1.2.3 From 2ee79f565da10b243b2362bc731686753839c2eb Mon Sep 17 00:00:00 2001 From: default Date: Mon, 20 Jan 2025 16:45:14 +0100 Subject: Fixed usage text. --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index db26252..a57adb5 100644 --- a/main.c +++ b/main.c @@ -51,10 +51,10 @@ int usage(void) printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n"); printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n"); printf("search {basedir} {uid} {regex} Searches posts by content\n"); - printf("export_csv {basedir} {uid} Exports data as CSV files into current directory\n"); + printf("export_csv {basedir} {uid} Exports data as CSV files\n"); printf("alias {basedir} {uid} {account} Sets account (@user@host or actor url) as an alias\n"); printf("migrate {basedir} {uid} Migrates to the account defined as the alias\n"); - printf("import_csv {basedir} {uid} Imports data from CSV files in the current directory\n"); + printf("import_csv {basedir} {uid} Imports data from CSV files\n"); printf("import_list {basedir} {uid} {file} Imports a Mastodon CSV list file\n"); printf("import_block_list {basedir} {uid} {file} Imports a Mastodon CSV block list file\n"); -- cgit v1.2.3