Added support for the 'Page' ActivityPub object.

So that you can follow and interact with lemmy channels.
This commit is contained in:
default 2023-07-13 21:01:15 +02:00
parent a05aa969d0
commit 2caeb550b9
2 changed files with 30 additions and 9 deletions

View file

@ -152,18 +152,19 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
int status = 0; int status = 0;
if (!xs_is_null(*id)) { if (!xs_is_null(*id)) {
xs *object = NULL; xs *msg = NULL;
/* is the object already there? */ /* is the object already there? */
if (!valid_status(object_get(*id, &object))) { if (!valid_status(object_get(*id, &msg))) {
/* no; download it */ /* no; download it */
status = activitypub_request(snac, *id, &object); status = activitypub_request(snac, *id, &msg);
if (valid_status(status)) { if (valid_status(status)) {
char *type = xs_dict_get(object, "type"); xs_dict *object = msg;
const char *type = xs_dict_get(object, "type");
/* get the id again from the object, as it may be different */ /* get the id again from the object, as it may be different */
char *nid = xs_dict_get(object, "id"); const char *nid = xs_dict_get(object, "id");
if (wrk && strcmp(nid, *id) != 0) { if (wrk && strcmp(nid, *id) != 0) {
snac_debug(snac, 1, snac_debug(snac, 1,
@ -173,8 +174,21 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
*id = *wrk; *id = *wrk;
} }
if (!xs_is_null(type) && strcmp(type, "Note") == 0) { if (xs_is_null(type))
char *actor = xs_dict_get(object, "attributedTo"); type = "(null)";
srv_debug(0, xs_fmt("timeline_request type %s '%s'", *id, type));
if (strcmp(type, "Create") == 0) {
/* some software like lemmy nest Announce + Create + Note */
if (!xs_is_null(object = xs_dict_get(object, "object")))
type = xs_dict_get(object, "type");
else
type = "(null)";
}
if (strcmp(type, "Note") == 0 || strcmp(type, "Page") == 0) {
const char *actor = xs_dict_get(object, "attributedTo");
/* request (and drop) the actor for this entry */ /* request (and drop) the actor for this entry */
if (!xs_is_null(actor)) if (!xs_is_null(actor))

11
html.c
View file

@ -189,8 +189,9 @@ xs_str *html_msg_icon(snac *snac, xs_str *os, const xs_dict *msg)
char *udate = NULL; char *udate = NULL;
char *url = NULL; char *url = NULL;
int priv = 0; int priv = 0;
const char *type = xs_dict_get(msg, "type");
if (strcmp(xs_dict_get(msg, "type"), "Note") == 0) if (strcmp(type, "Note") == 0 || strcmp(type, "Question") == 0 || strcmp(type, "Page") == 0)
url = xs_dict_get(msg, "id"); url = xs_dict_get(msg, "id");
priv = !is_msg_public(snac, msg); priv = !is_msg_public(snac, msg);
@ -856,7 +857,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
return xs_str_cat(os, s); return xs_str_cat(os, s);
} }
else else
if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0) { if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0 && strcmp(type, "Page") != 0) {
/* skip oddities */ /* skip oddities */
return os; return os;
} }
@ -974,6 +975,12 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
/* add the content */ /* add the content */
s = xs_str_cat(s, "</div>\n<div class=\"e-content snac-content\">\n"); /** **/ s = xs_str_cat(s, "</div>\n<div class=\"e-content snac-content\">\n"); /** **/
if (!xs_is_null(v = xs_dict_get(msg, "name"))) {
xs *es1 = encode_html(v);
xs *s1 = xs_fmt("<h3 class=\"snac-entry-title\">%s</h3>\n", es1);
s = xs_str_cat(s, s1);
}
/* is it sensitive? */ /* is it sensitive? */
if (!xs_is_null(v = xs_dict_get(msg, "sensitive")) && xs_type(v) == XSTYPE_TRUE) { if (!xs_is_null(v = xs_dict_get(msg, "sensitive")) && xs_type(v) == XSTYPE_TRUE) {
if (xs_is_null(v = xs_dict_get(msg, "summary")) || *v == '\0') if (xs_is_null(v = xs_dict_get(msg, "summary")) || *v == '\0')