mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Added support for the 'Page' ActivityPub object.
So that you can follow and interact with lemmy channels.
This commit is contained in:
parent
a05aa969d0
commit
2caeb550b9
2 changed files with 30 additions and 9 deletions
|
@ -152,18 +152,19 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
|
|||
int status = 0;
|
||||
|
||||
if (!xs_is_null(*id)) {
|
||||
xs *object = NULL;
|
||||
xs *msg = NULL;
|
||||
|
||||
/* is the object already there? */
|
||||
if (!valid_status(object_get(*id, &object))) {
|
||||
if (!valid_status(object_get(*id, &msg))) {
|
||||
/* no; download it */
|
||||
status = activitypub_request(snac, *id, &object);
|
||||
status = activitypub_request(snac, *id, &msg);
|
||||
|
||||
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 */
|
||||
char *nid = xs_dict_get(object, "id");
|
||||
const char *nid = xs_dict_get(object, "id");
|
||||
|
||||
if (wrk && strcmp(nid, *id) != 0) {
|
||||
snac_debug(snac, 1,
|
||||
|
@ -173,8 +174,21 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
|
|||
*id = *wrk;
|
||||
}
|
||||
|
||||
if (!xs_is_null(type) && strcmp(type, "Note") == 0) {
|
||||
char *actor = xs_dict_get(object, "attributedTo");
|
||||
if (xs_is_null(type))
|
||||
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 */
|
||||
if (!xs_is_null(actor))
|
||||
|
|
11
html.c
11
html.c
|
@ -189,8 +189,9 @@ xs_str *html_msg_icon(snac *snac, xs_str *os, const xs_dict *msg)
|
|||
char *udate = NULL;
|
||||
char *url = NULL;
|
||||
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");
|
||||
|
||||
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);
|
||||
}
|
||||
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 */
|
||||
return os;
|
||||
}
|
||||
|
@ -974,6 +975,12 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
|
|||
/* add the content */
|
||||
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? */
|
||||
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')
|
||||
|
|
Loading…
Reference in a new issue