commit 505084b
default
·
2023-08-23 07:44:46 +0000 UTC
parent 7e63766
Added some support for 'Article' object types.
2 files changed,
+11,
-6
M
html.c
+3,
-1
1@@ -192,7 +192,9 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
2 type = "(null)";
3 }
4
5- if (strcmp(type, "Note") == 0 || strcmp(type, "Page") == 0) {
6+ if (strcmp(type, "Note") == 0 ||
7+ strcmp(type, "Page") == 0 ||
8+ strcmp(type, "Article") == 0) {
9 const char *actor = xs_dict_get(object, "attributedTo");
10
11 /* request (and drop) the actor for this entry */
M
html.c
+8,
-5
1@@ -203,7 +203,8 @@ xs_str *html_msg_icon(xs_str *os, const xs_dict *msg)
2 int priv = 0;
3 const char *type = xs_dict_get(msg, "type");
4
5- if (strcmp(type, "Note") == 0 || strcmp(type, "Question") == 0 || strcmp(type, "Page") == 0)
6+ if (strcmp(type, "Note") == 0 || strcmp(type, "Question") == 0 ||
7+ strcmp(type, "Page") == 0 || strcmp(type, "Article") == 0)
8 url = xs_dict_get(msg, "id");
9
10 priv = !is_msg_public(msg);
11@@ -972,7 +973,8 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
12 return xs_str_cat(os, s);
13 }
14 else
15- if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0 && strcmp(type, "Page") != 0) {
16+ if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0 &&
17+ strcmp(type, "Page") != 0 && strcmp(type, "Article") != 0) {
18 /* skip oddities */
19 return os;
20 }
21@@ -1316,8 +1318,9 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
22 if (xs_is_null(url))
23 continue;
24
25- /* if it's a plain Link, check if it can be "rewritten" */
26- if (xs_list_len(attach) < 2 && strcmp(t, "Link") == 0) {
27+ /* infer MIME type from non-specific attachments */
28+ if (xs_list_len(attach) < 2 &&
29+ (strcmp(t, "Link") == 0 || strcmp(t, "Document") == 0)) {
30 const char *mt = xs_mime_by_ext(url);
31
32 if (xs_startswith(mt, "image/") ||
33@@ -1371,7 +1374,7 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
34
35 /* has this message an audience (i.e., comes from a channel or community)? */
36 const char *audience = xs_dict_get(msg, "audience");
37- if (strcmp(type, "Page") == 0 && !xs_is_null(audience)) {
38+ if (!xs_is_null(audience)) {
39 xs *es1 = encode_html(audience);
40 xs *s1 = xs_fmt("<p>(<a href=\"%s\" title=\"%s\">%s</a>)</p>\n",
41 audience, L("Source channel or community"), es1);