summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorGravatar default2025-01-05 09:34:00 +0100
committerGravatar default2025-01-05 09:34:00 +0100
commit3a1cae73265aebdbe678d94fbdc16edf3ccc643f (patch)
tree3c50341495d370dfeb7bfe0312ad5644d9c8f865 /activitypub.c
parentUse the site's CSS in the /share page. (diff)
downloadsnac2-3a1cae73265aebdbe678d94fbdc16edf3ccc643f.tar.gz
snac2-3a1cae73265aebdbe678d94fbdc16edf3ccc643f.tar.xz
snac2-3a1cae73265aebdbe678d94fbdc16edf3ccc643f.zip
Moved post language setting to msg_note(), where it really belongs.
On the way, posting from the Mastodon API sets the language accordingly.
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/activitypub.c b/activitypub.c
index e3a1f79..ea4d8ea 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1422,7 +1422,8 @@ xs_dict *msg_follow(snac *snac, const char *q)
1422 1422
1423 1423
1424xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts, 1424xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
1425 const xs_str *in_reply_to, const xs_list *attach, int priv) 1425 const xs_str *in_reply_to, const xs_list *attach,
1426 int priv, const char *lang_str)
1426/* creates a 'Note' message */ 1427/* creates a 'Note' message */
1427{ 1428{
1428 xs *ntid = tid(0); 1429 xs *ntid = tid(0);
@@ -1584,6 +1585,20 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
1584 if (xs_list_len(atls)) 1585 if (xs_list_len(atls))
1585 msg = xs_dict_append(msg, "attachment", atls); 1586 msg = xs_dict_append(msg, "attachment", atls);
1586 1587
1588 /* set language content map */
1589 if (xs_type(lang_str) == XSTYPE_STRING) {
1590 /* split at the first _ */
1591 xs *l0 = xs_split(lang_str, "_");
1592 const char *lang = xs_list_get(l0, 0);
1593
1594 if (xs_type(lang) == XSTYPE_STRING && strlen(lang) == 2) {
1595 /* a valid ISO language id */
1596 xs *cmap = xs_dict_new();
1597 cmap = xs_dict_set(cmap, lang, xs_dict_get(msg, "content"));
1598 msg = xs_dict_set(msg, "contentMap", cmap);
1599 }
1600 }
1601
1587 return msg; 1602 return msg;
1588} 1603}
1589 1604
@@ -1625,7 +1640,7 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
1625 const xs_list *opts, int multiple, int end_secs) 1640 const xs_list *opts, int multiple, int end_secs)
1626/* creates a Question message */ 1641/* creates a Question message */
1627{ 1642{
1628 xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0); 1643 xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL);
1629 int max = 8; 1644 int max = 8;
1630 xs_set seen; 1645 xs_set seen;
1631 1646