diff options
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/activitypub.c b/activitypub.c index 8771ee8..fb790d5 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -508,7 +508,7 @@ d_char *msg_follow(snac *snac, char *actor) | |||
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | 510 | ||
| 511 | d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to) | 511 | d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char *attach) |
| 512 | /* creates a 'Note' message */ | 512 | /* creates a 'Note' message */ |
| 513 | { | 513 | { |
| 514 | xs *ntid = tid(0); | 514 | xs *ntid = tid(0); |
| @@ -520,6 +520,7 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to) | |||
| 520 | xs *cc = xs_list_new(); | 520 | xs *cc = xs_list_new(); |
| 521 | xs *irt = NULL; | 521 | xs *irt = NULL; |
| 522 | xs *tag = NULL; | 522 | xs *tag = NULL; |
| 523 | xs *atls = NULL; | ||
| 523 | d_char *msg = msg_base(snac, "Note", id, NULL, "@now", NULL); | 524 | d_char *msg = msg_base(snac, "Note", id, NULL, "@now", NULL); |
| 524 | char *p, *v; | 525 | char *p, *v; |
| 525 | 526 | ||
| @@ -561,6 +562,30 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to) | |||
| 561 | else | 562 | else |
| 562 | irt = xs_val_new(XSTYPE_NULL); | 563 | irt = xs_val_new(XSTYPE_NULL); |
| 563 | 564 | ||
| 565 | /* create the attachment list, if there are any */ | ||
| 566 | if (!xs_is_null(attach) && *attach != '\0') { | ||
| 567 | xs *lsof1 = NULL; | ||
| 568 | |||
| 569 | if (xs_type(attach) == XSTYPE_STRING) { | ||
| 570 | lsof1 = xs_list_append(xs_list_new(), attach); | ||
| 571 | attach = lsof1; | ||
| 572 | } | ||
| 573 | |||
| 574 | atls = xs_list_new(); | ||
| 575 | while (xs_list_iter(&attach, &v)) { | ||
| 576 | xs *d = xs_dict_new(); | ||
| 577 | char *mime = xs_mime_by_ext(v); | ||
| 578 | |||
| 579 | d = xs_dict_append(d, "mediaType", mime); | ||
| 580 | d = xs_dict_append(d, "url", v); | ||
| 581 | d = xs_dict_append(d, "name", ""); | ||
| 582 | d = xs_dict_append(d, "type", | ||
| 583 | xs_startswith(mime, "image/") ? "Image" : "Document"); | ||
| 584 | |||
| 585 | atls = xs_list_append(atls, d); | ||
| 586 | } | ||
| 587 | } | ||
| 588 | |||
| 564 | if (tag == NULL) | 589 | if (tag == NULL) |
| 565 | tag = xs_list_new(); | 590 | tag = xs_list_new(); |
| 566 | 591 | ||
| @@ -594,6 +619,9 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to) | |||
| 594 | msg = xs_dict_append(msg, "inReplyTo", irt); | 619 | msg = xs_dict_append(msg, "inReplyTo", irt); |
| 595 | msg = xs_dict_append(msg, "tag", tag); | 620 | msg = xs_dict_append(msg, "tag", tag); |
| 596 | 621 | ||
| 622 | if (atls != NULL) | ||
| 623 | msg = xs_dict_append(msg, "attachment", atls); | ||
| 624 | |||
| 597 | return msg; | 625 | return msg; |
| 598 | } | 626 | } |
| 599 | 627 | ||