More work but signatures seem to still fail.

This commit is contained in:
default 2022-09-26 11:19:45 +02:00
parent acc467c034
commit fd6f71bfe3
6 changed files with 41 additions and 19 deletions

View file

@ -194,18 +194,27 @@ d_char *msg_update(snac *snac, char *object)
d_char *msg_admiration(snac *snac, char *object, char *type)
/* creates a Like or Announce message */
{
xs *ntid = tid(0);
xs *id = xs_fmt("%s/d/%d/%s", snac->actor, ntid, type);
d_char *msg = msg_base(snac, type, id, snac->actor, "");
xs *rcpts = xs_list_new();
xs *a_msg = NULL;
d_char *msg = NULL;
/* call the object */
timeline_request(snac, object, snac->actor);
rcpts = xs_list_append(rcpts, public_address);
if ((a_msg = timeline_find(snac, object)) != NULL) {
xs *ntid = tid(0);
xs *id = xs_fmt("%s/d/%d/%s", snac->actor, ntid, type);
xs *rcpts = xs_list_new();
msg = xs_dict_append(msg, "to", rcpts);
msg = xs_dict_append(msg, "object", object);
msg = msg_base(snac, type, id, snac->actor, "");
rcpts = xs_list_append(rcpts, public_address);
rcpts = xs_list_append(rcpts, xs_dict_get(a_msg, "attributedTo"));
msg = xs_dict_append(msg, "to", rcpts);
msg = xs_dict_append(msg, "object", object);
}
else
snac_log(snac, xs_fmt("msg_admiration cannot retrieve object %s", object));
return msg;
}
@ -372,9 +381,11 @@ void process_queue(snac *snac)
char *actor = xs_dict_get(q_item, "actor");
char *msg = xs_dict_get(q_item, "object");
int retries = xs_number_get(xs_dict_get(q_item, "retries"));
xs *payload = NULL;
int p_size = 0;
/* deliver */
status = send_to_actor(snac, actor, msg, NULL, 0);
status = send_to_actor(snac, actor, msg, &payload, &p_size);
if (!valid_status(status)) {
/* error sending; reenqueue? */
@ -420,12 +431,14 @@ d_char *recipient_list(snac *snac, char *msg, int expand_public)
char *p = fwers;
while (xs_list_iter(&p, &fw)) {
if (!xs_list_in(list, fw))
list = xs_list_append(list, fw);
char *actor = xs_dict_get(fw, "actor");
if (xs_list_in(list, actor) == -1)
list = xs_list_append(list, actor);
}
}
else
if (!xs_list_in(list, v))
if (xs_list_in(list, v) == -1)
list = xs_list_append(list, v);
}
}

6
data.c
View file

@ -302,8 +302,8 @@ int timeline_here(snac *snac, char *id)
d_char *timeline_find(snac *snac, char *id)
/* gets a message from the timeline by id */
{
xs *fn = _timeline_find_fn(snac, id);
xs *msg = NULL;
xs *fn = _timeline_find_fn(snac, id);
d_char *msg = NULL;
if (fn != NULL) {
FILE *f;
@ -820,7 +820,7 @@ void enqueue_output(snac *snac, char *msg, char *actor, int retries)
return;
}
int qrt = xs_number_get(xs_dict_get(srv_config, "query_retry_minutes"));
int qrt = xs_number_get(xs_dict_get(srv_config, "queue_retry_minutes"));
xs *ntid = tid(retries * 60 * qrt);
xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
xs *tfn = xs_fmt("%s.tmp", fn);

View file

@ -97,7 +97,7 @@ void httpd_connection(int rs)
xs *headers = NULL;
xs *q_path = NULL;
xs *payload = NULL;
int p_size;
int p_size = 0;
char *p;
f = xs_socket_accept(rs);

4
main.c
View file

@ -119,7 +119,9 @@ int main(int argc, char *argv[])
if (strcmp(cmd, "announce") == 0) {
xs *msg = msg_admiration(&snac, url, "Announce");
{
if (msg != NULL) {
post(&snac, msg);
xs *j = xs_json_dumps_pp(msg, 4);
printf("%s\n", j);
}

12
snac.c
View file

@ -142,7 +142,7 @@ void srv_archive(char *direction, char *req, char *payload, int p_size,
/* archives a connection */
{
/* obsessive archiving */
xs *date = xs_local_time("%Y%m%d%H%M%S");
xs *date = tid(0);
xs *dir = xs_fmt("%s/archive/%s", srv_basedir, date);
FILE *f;
@ -172,7 +172,10 @@ void srv_archive(char *direction, char *req, char *payload, int p_size,
if ((f = fopen(payload_fn, "w")) != NULL) {
xs *v1 = xs_json_loads(payload);
xs *j1 = xs_json_dumps_pp(v1, 4);
xs *j1 = NULL;
if (v1 != NULL)
j1 = xs_json_dumps_pp(v1, 4);
if (j1 != NULL)
fwrite(j1, strlen(j1), 1, f);
@ -200,7 +203,10 @@ void srv_archive(char *direction, char *req, char *payload, int p_size,
if ((f = fopen(body_fn, "w")) != NULL) {
xs *v1 = xs_json_loads(body);
xs *j1 = xs_json_dumps_pp(v1, 4);
xs *j1 = NULL;
if (v1 != NULL)
j1 = xs_json_dumps_pp(v1, 4);
if (j1 != NULL)
fwrite(j1, strlen(j1), 1, f);

1
snac.h
View file

@ -94,6 +94,7 @@ int actor_request(snac *snac, char *actor, d_char **data);
int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size);
int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size);
void process_queue(snac *snac);
void post(snac *snac, char *msg);
int activitypub_get_handler(d_char *req, char *q_path,
char **body, int *b_size, char **ctype);
int activitypub_post_handler(d_char *req, char *q_path,