summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGravatar shtrophic2025-02-15 14:37:36 +0100
committerGravatar shtrophic2025-02-15 14:37:36 +0100
commit7611a6bee4bcbad2f1710aafa99aba730e5cf995 (patch)
tree33ab7bee30379e16f6869b2efda5494be8aeb858 /main.c
parentenforce tls when supported && add tests (diff)
parentVersion 2.72 RELEASED. (diff)
downloadsnac2-7611a6bee4bcbad2f1710aafa99aba730e5cf995.tar.gz
snac2-7611a6bee4bcbad2f1710aafa99aba730e5cf995.tar.xz
snac2-7611a6bee4bcbad2f1710aafa99aba730e5cf995.zip
Merge tag '2.72' into curl-smtp
Version 2.72 RELEASED.
Diffstat (limited to 'main.c')
-rw-r--r--main.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/main.c b/main.c
index a57adb5..1cd6580 100644
--- a/main.c
+++ b/main.c
@@ -11,6 +11,7 @@
11#include "snac.h" 11#include "snac.h"
12 12
13#include <sys/stat.h> 13#include <sys/stat.h>
14#include <sys/wait.h>
14 15
15int usage(void) 16int usage(void)
16{ 17{
@@ -49,6 +50,7 @@ int usage(void)
49 printf("unblock {basedir} {instance_url} Unblocks a full instance\n"); 50 printf("unblock {basedir} {instance_url} Unblocks a full instance\n");
50 printf("limit {basedir} {uid} {actor} Limits an actor (drops their announces)\n"); 51 printf("limit {basedir} {uid} {actor} Limits an actor (drops their announces)\n");
51 printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n"); 52 printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n");
53 printf("unmute {basedir} {uid} {actor} Unmutes a previously muted actor\n");
52 printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n"); 54 printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n");
53 printf("search {basedir} {uid} {regex} Searches posts by content\n"); 55 printf("search {basedir} {uid} {regex} Searches posts by content\n");
54 printf("export_csv {basedir} {uid} Exports data as CSV files\n"); 56 printf("export_csv {basedir} {uid} Exports data as CSV files\n");
@@ -446,6 +448,18 @@ int main(int argc, char *argv[])
446 return 0; 448 return 0;
447 } 449 }
448 450
451 if (strcmp(cmd, "unmute") == 0) { /** **/
452 if (is_muted(&snac, url)) {
453 unmute(&snac, url);
454
455 printf("%s unmuted\n", url);
456 }
457 else
458 printf("%s actor is not muted\n", url);
459
460 return 0;
461 }
462
449 if (strcmp(cmd, "search") == 0) { /** **/ 463 if (strcmp(cmd, "search") == 0) { /** **/
450 int to; 464 int to;
451 465
@@ -663,19 +677,25 @@ int main(int argc, char *argv[])
663 677
664 if (strcmp(url, "-e") == 0) { 678 if (strcmp(url, "-e") == 0) {
665 /* get the content from an editor */ 679 /* get the content from an editor */
680#define EDITOR "$EDITOR "
681 char cmd[] = EDITOR "/tmp/snac-XXXXXX";
666 FILE *f; 682 FILE *f;
667 683 int fd = mkstemp(cmd + strlen(EDITOR));
668 unlink("/tmp/snac-edit.txt"); 684
669 system("$EDITOR /tmp/snac-edit.txt"); 685 if (fd >= 0) {
670 686 int status = system(cmd);
671 if ((f = fopen("/tmp/snac-edit.txt", "r")) != NULL) { 687
672 content = xs_readall(f); 688 if (WIFEXITED(status) && WEXITSTATUS(status) == 0 && (f = fdopen(fd, "r")) != NULL) {
673 fclose(f); 689 content = xs_readall(f);
674 690 fclose(f);
675 unlink("/tmp/snac-edit.txt"); 691 unlink(cmd + strlen(EDITOR));
676 } 692 } else {
677 else { 693 printf("Nothing to send\n");
678 printf("Nothing to send\n"); 694 close(fd);
695 return 1;
696 }
697 } else {
698 fprintf(stderr, "Temp file creation failed\n");
679 return 1; 699 return 1;
680 } 700 }
681 } 701 }
@@ -687,6 +707,11 @@ int main(int argc, char *argv[])
687 else 707 else
688 content = xs_dup(url); 708 content = xs_dup(url);
689 709
710 if (!content || !*content) {
711 printf("Nothing to send\n");
712 return 1;
713 }
714
690 int scope = 0; 715 int scope = 0;
691 if (strcmp(cmd, "note_mention") == 0) 716 if (strcmp(cmd, "note_mention") == 0)
692 scope = 1; 717 scope = 1;