summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.c25
-rw-r--r--html.c22
-rw-r--r--snac.h2
3 files changed, 31 insertions, 18 deletions
diff --git a/activitypub.c b/activitypub.c
index 663ee3f..e52db31 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -620,7 +620,7 @@ d_char *msg_follow(snac *snac, char *url_or_uid)
}
-d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char *attach)
+xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_to, xs_list *attach)
/* creates a 'Note' message */
{
xs *ntid = tid(0);
@@ -633,8 +633,9 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
xs *irt = NULL;
xs *tag = NULL;
xs *atls = NULL;
- d_char *msg = msg_base(snac, "Note", id, NULL, "@now", NULL);
- char *p, *v;
+ xs_dict *msg = msg_base(snac, "Note", id, NULL, "@now", NULL);
+ xs_list *p;
+ xs_val *v;
if (rcpts == NULL)
to = xs_list_new();
@@ -700,22 +701,18 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
irt = xs_val_new(XSTYPE_NULL);
/* create the attachment list, if there are any */
- if (!xs_is_null(attach) && *attach != '\0') {
- xs *lsof1 = NULL;
-
- if (xs_type(attach) == XSTYPE_STRING) {
- lsof1 = xs_list_append(xs_list_new(), attach);
- attach = lsof1;
- }
-
+ if (!xs_is_null(attach)) {
atls = xs_list_new();
+
while (xs_list_iter(&attach, &v)) {
xs *d = xs_dict_new();
- char *mime = xs_mime_by_ext(v);
+ char *url = xs_list_get(v, 0);
+ char *alt = xs_list_get(v, 1);
+ char *mime = xs_mime_by_ext(url);
d = xs_dict_append(d, "mediaType", mime);
- d = xs_dict_append(d, "url", v);
- d = xs_dict_append(d, "name", "");
+ d = xs_dict_append(d, "url", url);
+ d = xs_dict_append(d, "name", alt);
d = xs_dict_append(d, "type",
xs_startswith(mime, "image/") ? "Image" : "Document");
diff --git a/html.c b/html.c
index 7aede65..7a388a1 100644
--- a/html.c
+++ b/html.c
@@ -1352,11 +1352,22 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
char *to = xs_dict_get(p_vars, "to");
char *sensitive = xs_dict_get(p_vars, "sensitive");
char *edit_id = xs_dict_get(p_vars, "edit_id");
+ char *alt_text = xs_dict_get(p_vars, "alt_text");
xs *attach_list = xs_list_new();
+ /* default alt text */
+ if (xs_is_null(alt_text))
+ alt_text = "";
+
/* is attach_url set? */
- if (!xs_is_null(attach_url) && *attach_url != '\0')
- attach_list = xs_list_append(attach_list, attach_url);
+ if (!xs_is_null(attach_url) && *attach_url != '\0') {
+ xs *l = xs_list_new();
+
+ l = xs_list_append(l, attach_url);
+ l = xs_list_append(l, alt_text);
+
+ attach_list = xs_list_append(attach_list, l);
+ }
/* is attach_file set? */
if (!xs_is_null(attach_file) && xs_type(attach_file) == XSTYPE_LIST) {
@@ -1373,7 +1384,12 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
/* store */
static_put(&snac, id, payload + fo, fs);
- attach_list = xs_list_append(attach_list, url);
+ xs *l = xs_list_new();
+
+ l = xs_list_append(l, url);
+ l = xs_list_append(l, alt_text);
+
+ attach_list = xs_list_append(attach_list, l);
}
}
diff --git a/snac.h b/snac.h
index 8a0337a..1678e86 100644
--- a/snac.h
+++ b/snac.h
@@ -151,7 +151,7 @@ const char *default_avatar_base64(void);
d_char *msg_admiration(snac *snac, char *object, char *type);
d_char *msg_create(snac *snac, char *object);
d_char *msg_follow(snac *snac, char *actor);
-d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char *attach);
+xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_to, xs_list *attach);
d_char *msg_undo(snac *snac, char *object);
d_char *msg_delete(snac *snac, char *id);
d_char *msg_actor(snac *snac);