commit 00eb86d

default  ·  2025-01-06 17:04:56 +0000 UTC
parent f6e06be
New command-line operation 'note_unlisted'.
1 files changed,  +10, -1
M main.c
M main.c
+10, -1
 1@@ -33,6 +33,7 @@ int usage(void)
 2     printf("insert {basedir} {uid} {url}         Requests an object and inserts it into the timeline\n");
 3     printf("actor {basedir} [{uid}] {url}        Requests an actor\n");
 4     printf("note {basedir} {uid} {text} [files...] Sends a note with optional attachments\n");
 5+    printf("note_unlisted {basedir} {uid} {text} [files...] Sends an unlisted note with optional attachments\n");
 6     printf("boost|announce {basedir} {uid} {url} Boosts (announces) a post\n");
 7     printf("unboost {basedir} {uid} {url}        Unboosts a post\n");
 8     printf("resetpwd {basedir} {uid}             Resets the password of a user\n");
 9@@ -603,7 +604,7 @@ int main(int argc, char *argv[])
10         return 0;
11     }
12 
13-    if (strcmp(cmd, "note") == 0) { /** **/
14+    if (strcmp(cmd, "note") == 0 || strcmp(cmd, "note_unlisted") == 0) { /** **/
15         xs *content = NULL;
16         xs *msg = NULL;
17         xs *c_msg = NULL;
18@@ -669,6 +670,14 @@ int main(int argc, char *argv[])
19 
20         msg = msg_note(&snac, content, NULL, NULL, attl, 0, getenv("LANG"));
21 
22+        if (strcmp(cmd, "note_unlisted") == 0) {
23+            /* according to Mastodon, "unlisted" posts (now called "quiet public")
24+               has the public address as a cc instead of to, so toggle it */
25+            xs *to = xs_dup(xs_dict_get(msg, "to"));
26+            msg = xs_dict_set(msg, "cc", to);
27+            msg = xs_dict_set(msg, "to", xs_stock(XSTYPE_LIST));
28+        }
29+
30         c_msg = msg_create(&snac, msg);
31 
32         if (dbglevel) {