aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorshtrophic <christoph@liebender.dev>2025-02-15 14:37:36 +0100
committershtrophic <christoph@liebender.dev>2025-02-15 14:37:36 +0100
commit7611a6bee4bcbad2f1710aafa99aba730e5cf995 (patch)
tree33ab7bee30379e16f6869b2efda5494be8aeb858 /main.c
parent3d96c576287736ebdf87e4a7b956842a6c6e055f (diff)
parent3d705b22a67ee913b9bd4473277430bd481cef25 (diff)
Merge tag '2.72' into curl-smtp
Version 2.72 RELEASED.
Diffstat (limited to 'main.c')
-rw-r--r--main.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/main.c b/main.c
index a57adb5..1cd6580 100644
--- a/main.c
+++ b/main.c
@@ -11,6 +11,7 @@
#include "snac.h"
#include <sys/stat.h>
+#include <sys/wait.h>
int usage(void)
{
@@ -49,6 +50,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 +448,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;
@@ -663,19 +677,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;
+ int fd = mkstemp(cmd + strlen(EDITOR));
- unlink("/tmp/snac-edit.txt");
- system("$EDITOR /tmp/snac-edit.txt");
+ if (fd >= 0) {
+ int status = system(cmd);
- 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");
+ 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;
}
}
@@ -687,6 +707,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;