From 6097ba55cf96444aac7fb9b74295722e8e5c3810 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 26 Jan 2025 17:55:36 +0100 Subject: New command-line option 'unmute'. --- main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index a57adb5..347c495 100644 --- a/main.c +++ b/main.c @@ -49,6 +49,7 @@ int usage(void) printf("unblock {basedir} {instance_url} Unblocks a full instance\n"); printf("limit {basedir} {uid} {actor} Limits an actor (drops their announces)\n"); printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n"); + printf("unmute {basedir} {uid} {actor} Unmutes a previously muted 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\n"); @@ -446,6 +447,18 @@ int main(int argc, char *argv[]) return 0; } + if (strcmp(cmd, "unmute") == 0) { /** **/ + if (is_muted(&snac, url)) { + unmute(&snac, url); + + printf("%s unmuted\n", url); + } + else + printf("%s actor is not muted\n", url); + + return 0; + } + if (strcmp(cmd, "search") == 0) { /** **/ int to; -- cgit v1.2.3 From a356ca255acf2119f10acbe577c3f8008ad8e160 Mon Sep 17 00:00:00 2001 From: Santtu Lakkala Date: Sat, 1 Feb 2025 14:31:18 +0200 Subject: Allow multiple editors at the same time Instead of a hard-coded message file, use mkstemp() to have an unique temp file for each invocation. --- main.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 347c495..58a46de 100644 --- a/main.c +++ b/main.c @@ -676,19 +676,25 @@ int main(int argc, char *argv[]) if (strcmp(url, "-e") == 0) { /* get the content from an editor */ +#define EDITOR "$EDITOR " + char cmd[] = EDITOR "/tmp/snac-XXXXXX"; FILE *f; - - unlink("/tmp/snac-edit.txt"); - system("$EDITOR /tmp/snac-edit.txt"); - - if ((f = fopen("/tmp/snac-edit.txt", "r")) != NULL) { - content = xs_readall(f); - fclose(f); - - unlink("/tmp/snac-edit.txt"); - } - else { - printf("Nothing to send\n"); + int fd = mkstemp(cmd + strlen(EDITOR)); + + if (fd >= 0) { + int status = system(cmd); + + if (WIFEXITED(status) && WEXITSTATUS(status) == 0 && (f = fdopen(fd, "r")) != NULL) { + content = xs_readall(f); + fclose(f); + unlink(cmd + strlen(EDITOR)); + } else { + printf("Nothing to send\n"); + close(fd); + return 1; + } + } else { + fprintf(stderr, "Temp file creation failed\n"); return 1; } } @@ -700,6 +706,11 @@ int main(int argc, char *argv[]) else content = xs_dup(url); + if (!content || !*content) { + printf("Nothing to send\n"); + return 1; + } + int scope = 0; if (strcmp(cmd, "note_mention") == 0) scope = 1; -- cgit v1.2.3 From 3318f1596bbb2853a8305194204084b32790fbd7 Mon Sep 17 00:00:00 2001 From: default Date: Wed, 5 Feb 2025 11:00:30 +0100 Subject: Fixed compilation failure in FreeBSD. --- main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'main.c') diff --git a/main.c b/main.c index 58a46de..1cd6580 100644 --- a/main.c +++ b/main.c @@ -11,6 +11,7 @@ #include "snac.h" #include +#include int usage(void) { -- cgit v1.2.3