Browse Source

New command-line operation 'note_unlisted'.

default 2 months ago
parent
commit
00eb86deaf
1 changed files with 10 additions and 1 deletions
  1. 10 1
      main.c

+ 10 - 1
main.c

@@ -33,6 +33,7 @@ int usage(void)
     printf("insert {basedir} {uid} {url}         Requests an object and inserts it into the timeline\n");
     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("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");
@@ -603,7 +604,7 @@ int main(int argc, char *argv[])
         return 0;
     }
 
-    if (strcmp(cmd, "note") == 0) { /** **/
+    if (strcmp(cmd, "note") == 0 || strcmp(cmd, "note_unlisted") == 0) { /** **/
         xs *content = NULL;
         xs *msg = NULL;
         xs *c_msg = NULL;
@@ -669,6 +670,14 @@ int main(int argc, char *argv[])
 
         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));
+        }
+
         c_msg = msg_create(&snac, msg);
 
         if (dbglevel) {