summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.c2
-rw-r--r--data.c10
-rw-r--r--html.c14
-rw-r--r--mastoapi.c4
-rw-r--r--snac.h2
5 files changed, 12 insertions, 20 deletions
diff --git a/activitypub.c b/activitypub.c
index 2c20e63..6fb6bf5 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -117,7 +117,7 @@ int actor_request(snac *snac, const char *actor, xs_dict **data)
117 *data = NULL; 117 *data = NULL;
118 118
119 /* get from disk first */ 119 /* get from disk first */
120 status = actor_get(snac, actor, data); 120 status = actor_get(actor, data);
121 121
122 if (status != 200) { 122 if (status != 200) {
123 /* actor data non-existent or stale: get from the net */ 123 /* actor data non-existent or stale: get from the net */
diff --git a/data.c b/data.c
index d7643e2..73192ba 100644
--- a/data.c
+++ b/data.c
@@ -1439,20 +1439,12 @@ int actor_add(const char *actor, xs_dict *msg)
1439} 1439}
1440 1440
1441 1441
1442int actor_get(snac *snac1, const char *actor, xs_dict **data) 1442int actor_get(const char *actor, xs_dict **data)
1443/* returns an already downloaded actor */ 1443/* returns an already downloaded actor */
1444{ 1444{
1445 int status = 200; 1445 int status = 200;
1446 xs_dict *d = NULL; 1446 xs_dict *d = NULL;
1447 1447
1448 if (strcmp(actor, snac1->actor) == 0) {
1449 /* this actor */
1450 if (data)
1451 *data = msg_actor(snac1);
1452
1453 return status;
1454 }
1455
1456 if (xs_startswith(actor, srv_baseurl)) { 1448 if (xs_startswith(actor, srv_baseurl)) {
1457 /* it's a (possible) local user */ 1449 /* it's a (possible) local user */
1458 xs *l = xs_split(actor, "/"); 1450 xs *l = xs_split(actor, "/");
diff --git a/html.c b/html.c
index 58501f2..5c2c4d7 100644
--- a/html.c
+++ b/html.c
@@ -188,7 +188,7 @@ xs_str *html_actor_icon(xs_str *os, char *actor,
188} 188}
189 189
190 190
191xs_str *html_msg_icon(snac *snac, xs_str *os, const xs_dict *msg) 191xs_str *html_msg_icon(xs_str *os, const xs_dict *msg)
192{ 192{
193 char *actor_id; 193 char *actor_id;
194 xs *actor = NULL; 194 xs *actor = NULL;
@@ -196,7 +196,7 @@ xs_str *html_msg_icon(snac *snac, xs_str *os, const xs_dict *msg)
196 if ((actor_id = xs_dict_get(msg, "attributedTo")) == NULL) 196 if ((actor_id = xs_dict_get(msg, "attributedTo")) == NULL)
197 actor_id = xs_dict_get(msg, "actor"); 197 actor_id = xs_dict_get(msg, "actor");
198 198
199 if (actor_id && valid_status(actor_get(snac, actor_id, &actor))) { 199 if (actor_id && valid_status(actor_get(actor_id, &actor))) {
200 char *date = NULL; 200 char *date = NULL;
201 char *udate = NULL; 201 char *udate = NULL;
202 char *url = NULL; 202 char *url = NULL;
@@ -870,7 +870,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
870 xs *s1 = xs_fmt("<div class=\"snac-origin\">%s</div>\n", L("follows you")); 870 xs *s1 = xs_fmt("<div class=\"snac-origin\">%s</div>\n", L("follows you"));
871 s = xs_str_cat(s, s1); 871 s = xs_str_cat(s, s1);
872 872
873 s = html_msg_icon(snac, s, msg); 873 s = html_msg_icon(s, msg);
874 874
875 s = xs_str_cat(s, "</div>\n</div>\n"); 875 s = xs_str_cat(s, "</div>\n</div>\n");
876 876
@@ -894,7 +894,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
894 if (is_muted(snac, actor)) 894 if (is_muted(snac, actor))
895 return os; 895 return os;
896 896
897 if (strcmp(actor, snac->actor) != 0 && !valid_status(actor_get(snac, actor, NULL))) 897 if (strcmp(actor, snac->actor) != 0 && !valid_status(actor_get(actor, NULL)))
898 return os; 898 return os;
899 899
900 if (level == 0) 900 if (level == 0)
@@ -990,7 +990,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
990 } 990 }
991 } 991 }
992 992
993 s = html_msg_icon(snac, s, msg); 993 s = html_msg_icon(s, msg);
994 994
995 /* add the content */ 995 /* add the content */
996 s = xs_str_cat(s, "</div>\n<div class=\"e-content snac-content\">\n"); /** **/ 996 s = xs_str_cat(s, "</div>\n<div class=\"e-content snac-content\">\n"); /** **/
@@ -1450,7 +1450,7 @@ xs_str *html_people_list(snac *snac, xs_str *os, xs_list *list, const char *head
1450 xs *md5 = xs_md5_hex(actor_id, strlen(actor_id)); 1450 xs *md5 = xs_md5_hex(actor_id, strlen(actor_id));
1451 xs *actor = NULL; 1451 xs *actor = NULL;
1452 1452
1453 if (valid_status(actor_get(snac, actor_id, &actor))) { 1453 if (valid_status(actor_get(actor_id, &actor))) {
1454 s = xs_str_cat(s, "<div class=\"snac-post\">\n<div class=\"snac-post-header\">\n"); 1454 s = xs_str_cat(s, "<div class=\"snac-post\">\n<div class=\"snac-post-header\">\n");
1455 1455
1456 s = html_actor_icon(s, actor, xs_dict_get(actor, "published"), NULL, NULL, 0); 1456 s = html_actor_icon(s, actor, xs_dict_get(actor, "published"), NULL, NULL, 0);
@@ -1608,7 +1608,7 @@ xs_str *html_notifications(snac *snac)
1608 const char *actor_id = xs_dict_get(noti, "actor"); 1608 const char *actor_id = xs_dict_get(noti, "actor");
1609 xs *actor = NULL; 1609 xs *actor = NULL;
1610 1610
1611 if (!valid_status(actor_get(snac, actor_id, &actor))) 1611 if (!valid_status(actor_get(actor_id, &actor)))
1612 continue; 1612 continue;
1613 1613
1614 xs *a_name = actor_name(actor); 1614 xs *a_name = actor_name(actor);
diff --git a/mastoapi.c b/mastoapi.c
index 25e54d3..980d900 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -632,7 +632,7 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
632/* converts an ActivityPub note to a Mastodon status */ 632/* converts an ActivityPub note to a Mastodon status */
633{ 633{
634 xs *actor = NULL; 634 xs *actor = NULL;
635 actor_get(snac, xs_dict_get(msg, "attributedTo"), &actor); 635 actor_get(xs_dict_get(msg, "attributedTo"), &actor);
636 636
637 /* if the author is not here, discard */ 637 /* if the author is not here, discard */
638 if (actor == NULL) 638 if (actor == NULL)
@@ -1310,7 +1310,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1310 xs *actor = NULL; 1310 xs *actor = NULL;
1311 xs *entry = NULL; 1311 xs *entry = NULL;
1312 1312
1313 if (!valid_status(actor_get(&snac1, xs_dict_get(noti, "actor"), &actor))) 1313 if (!valid_status(actor_get(xs_dict_get(noti, "actor"), &actor)))
1314 continue; 1314 continue;
1315 1315
1316 if (objid != NULL && !valid_status(object_get(objid, &entry))) 1316 if (objid != NULL && !valid_status(object_get(objid, &entry)))
diff --git a/snac.h b/snac.h
index fed9309..1365816 100644
--- a/snac.h
+++ b/snac.h
@@ -141,7 +141,7 @@ void hide(snac *snac, const char *id);
141int is_hidden(snac *snac, const char *id); 141int is_hidden(snac *snac, const char *id);
142 142
143int actor_add(const char *actor, xs_dict *msg); 143int actor_add(const char *actor, xs_dict *msg);
144int actor_get(snac *snac, const char *actor, xs_dict **data); 144int actor_get(const char *actor, xs_dict **data);
145 145
146int static_get(snac *snac, const char *id, xs_val **data, int *size, const char *inm, xs_str **etag); 146int static_get(snac *snac, const char *id, xs_val **data, int *size, const char *inm, xs_str **etag);
147void static_put(snac *snac, const char *id, const char *data, int size); 147void static_put(snac *snac, const char *id, const char *data, int size);