summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-08-23 09:44:46 +0200
committerdefault <nobody@localhost>2023-08-23 09:44:46 +0200
commit505084bab74ec5a2a2c7c662cf7efe739fba3afa (patch)
tree6bf716d08939f454049bcbb8c808427467c81c36
parent7e63766e4a609ee0877474332f6406cc4fd9dbd9 (diff)
Added some support for 'Article' object types.
-rw-r--r--activitypub.c4
-rw-r--r--html.c13
2 files changed, 11 insertions, 6 deletions
diff --git a/activitypub.c b/activitypub.c
index da5ea95..35e9991 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -192,7 +192,9 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
type = "(null)";
}
- if (strcmp(type, "Note") == 0 || strcmp(type, "Page") == 0) {
+ if (strcmp(type, "Note") == 0 ||
+ strcmp(type, "Page") == 0 ||
+ strcmp(type, "Article") == 0) {
const char *actor = xs_dict_get(object, "attributedTo");
/* request (and drop) the actor for this entry */
diff --git a/html.c b/html.c
index c9793a6..b2c6595 100644
--- a/html.c
+++ b/html.c
@@ -203,7 +203,8 @@ xs_str *html_msg_icon(xs_str *os, const xs_dict *msg)
int priv = 0;
const char *type = xs_dict_get(msg, "type");
- if (strcmp(type, "Note") == 0 || strcmp(type, "Question") == 0 || strcmp(type, "Page") == 0)
+ if (strcmp(type, "Note") == 0 || strcmp(type, "Question") == 0 ||
+ strcmp(type, "Page") == 0 || strcmp(type, "Article") == 0)
url = xs_dict_get(msg, "id");
priv = !is_msg_public(msg);
@@ -972,7 +973,8 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
return xs_str_cat(os, s);
}
else
- if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0 && strcmp(type, "Page") != 0) {
+ if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0 &&
+ strcmp(type, "Page") != 0 && strcmp(type, "Article") != 0) {
/* skip oddities */
return os;
}
@@ -1316,8 +1318,9 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
if (xs_is_null(url))
continue;
- /* if it's a plain Link, check if it can be "rewritten" */
- if (xs_list_len(attach) < 2 && strcmp(t, "Link") == 0) {
+ /* infer MIME type from non-specific attachments */
+ if (xs_list_len(attach) < 2 &&
+ (strcmp(t, "Link") == 0 || strcmp(t, "Document") == 0)) {
const char *mt = xs_mime_by_ext(url);
if (xs_startswith(mt, "image/") ||
@@ -1371,7 +1374,7 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
/* has this message an audience (i.e., comes from a channel or community)? */
const char *audience = xs_dict_get(msg, "audience");
- if (strcmp(type, "Page") == 0 && !xs_is_null(audience)) {
+ if (!xs_is_null(audience)) {
xs *es1 = encode_html(audience);
xs *s1 = xs_fmt("<p>(<a href=\"%s\" title=\"%s\">%s</a>)</p>\n",
audience, L("Source channel or community"), es1);