commit 6776a73
default
·
2025-02-27 18:03:01 +0000 UTC
parent 1cce6d8
Some tweaks to timeline_request().
1 files changed,
+50,
-50
+50,
-50
1@@ -390,71 +390,71 @@ int timeline_request(snac *snac, const char **id, xs_str **wrk, int level)
2 }
3
4 /* is the object already there? */
5- if (!valid_status(object_get(*id, &msg))) {
6+ if (!valid_status((status = object_get(*id, &msg)))) {
7 /* no; download it */
8 status = activitypub_request(snac, *id, &msg);
9+ }
10
11- if (valid_status(status)) {
12- const xs_dict *object = msg;
13- const char *type = xs_dict_get(object, "type");
14+ if (valid_status(status)) {
15+ const xs_dict *object = msg;
16+ const char *type = xs_dict_get(object, "type");
17
18- /* get the id again from the object, as it may be different */
19- const char *nid = xs_dict_get(object, "id");
20+ /* get the id again from the object, as it may be different */
21+ const char *nid = xs_dict_get(object, "id");
22
23- if (xs_type(nid) != XSTYPE_STRING)
24- return 0;
25+ if (xs_type(nid) != XSTYPE_STRING)
26+ return 0;
27
28- if (wrk && strcmp(nid, *id) != 0) {
29- snac_debug(snac, 1,
30- xs_fmt("timeline_request canonical id for %s is %s", *id, nid));
31+ if (wrk && strcmp(nid, *id) != 0) {
32+ snac_debug(snac, 1,
33+ xs_fmt("timeline_request canonical id for %s is %s", *id, nid));
34
35- *wrk = xs_dup(nid);
36- *id = *wrk;
37- }
38+ *wrk = xs_dup(nid);
39+ *id = *wrk;
40+ }
41
42- if (xs_is_null(type))
43- type = "(null)";
44+ if (xs_is_null(type))
45+ type = "(null)";
46
47- srv_debug(2, xs_fmt("timeline_request type %s '%s'", nid, type));
48+ srv_debug(2, xs_fmt("timeline_request type %s '%s'", nid, type));
49
50- if (strcmp(type, "Create") == 0) {
51- /* some software like lemmy nest Announce + Create + Note */
52- if (!xs_is_null(object = xs_dict_get(object, "object"))) {
53- type = xs_dict_get(object, "type");
54- nid = xs_dict_get(object, "id");
55- }
56- else
57- type = "(null)";
58+ if (strcmp(type, "Create") == 0) {
59+ /* some software like lemmy nest Announce + Create + Note */
60+ if (!xs_is_null(object = xs_dict_get(object, "object"))) {
61+ type = xs_dict_get(object, "type");
62+ nid = xs_dict_get(object, "id");
63 }
64+ else
65+ type = "(null)";
66+ }
67
68- if (xs_match(type, POSTLIKE_OBJECT_TYPE)) {
69- if (content_match("filter_reject.txt", object))
70- snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid));
71- else
72- if (blocked_hashtag_check(snac, object))
73- snac_log(snac, xs_fmt("timeline_request rejected by hashtag %s", nid));
74- else {
75- const char *actor = get_atto(object);
76-
77- if (!xs_is_null(actor)) {
78- /* request (and drop) the actor for this entry */
79- if (!valid_status(actor_request(snac, actor, NULL))) {
80- /* failed? retry later */
81- enqueue_actor_refresh(snac, actor, 60);
82- }
83+ if (xs_match(type, POSTLIKE_OBJECT_TYPE)) {
84+ if (content_match("filter_reject.txt", object))
85+ snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid));
86+ else
87+ if (blocked_hashtag_check(snac, object))
88+ snac_log(snac, xs_fmt("timeline_request rejected by hashtag %s", nid));
89+ else {
90+ const char *actor = get_atto(object);
91+
92+ if (!xs_is_null(actor)) {
93+ /* request (and drop) the actor for this entry */
94+ if (!valid_status(actor_request(snac, actor, NULL))) {
95+ /* failed? retry later */
96+ enqueue_actor_refresh(snac, actor, 60);
97+ }
98
99- /* does it have an ancestor? */
100- const char *in_reply_to = get_in_reply_to(object);
101+ /* does it have an ancestor? */
102+ const char *in_reply_to = get_in_reply_to(object);
103
104- /* store */
105- timeline_add(snac, nid, object);
106+ /* store */
107+ timeline_add(snac, nid, object);
108
109- /* redistribute to lists for this user */
110- list_distribute(snac, actor, object);
111+ /* redistribute to lists for this user */
112+ list_distribute(snac, actor, object);
113
114- /* recurse! */
115- timeline_request(snac, &in_reply_to, NULL, level + 1);
116- }
117+ /* recurse! */
118+ timeline_request(snac, &in_reply_to, NULL, level + 1);
119 }
120 }
121 }
122@@ -2360,7 +2360,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
123 xs *this_relay = xs_fmt("%s/relay", srv_baseurl);
124
125 if (strcmp(actor, this_relay) != 0) {
126- if (timeline_admire(snac, object, actor, 0) == HTTP_STATUS_CREATED)
127+ if (valid_status(timeline_admire(snac, object, actor, 0)))
128 snac_log(snac, xs_fmt("new 'Announce' %s %s", actor, object));
129 else
130 snac_log(snac, xs_fmt("repeated 'Announce' from %s to %s",