mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-24 22:15:04 +00:00
More work but signatures seem to still fail.
This commit is contained in:
parent
acc467c034
commit
fd6f71bfe3
6 changed files with 41 additions and 19 deletions
|
@ -194,18 +194,27 @@ d_char *msg_update(snac *snac, char *object)
|
||||||
d_char *msg_admiration(snac *snac, char *object, char *type)
|
d_char *msg_admiration(snac *snac, char *object, char *type)
|
||||||
/* creates a Like or Announce message */
|
/* creates a Like or Announce message */
|
||||||
{
|
{
|
||||||
xs *ntid = tid(0);
|
xs *a_msg = NULL;
|
||||||
xs *id = xs_fmt("%s/d/%d/%s", snac->actor, ntid, type);
|
d_char *msg = NULL;
|
||||||
d_char *msg = msg_base(snac, type, id, snac->actor, "");
|
|
||||||
xs *rcpts = xs_list_new();
|
|
||||||
|
|
||||||
/* call the object */
|
/* call the object */
|
||||||
timeline_request(snac, object, snac->actor);
|
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 = msg_base(snac, type, id, snac->actor, "");
|
||||||
msg = xs_dict_append(msg, "object", object);
|
|
||||||
|
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;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -372,9 +381,11 @@ void process_queue(snac *snac)
|
||||||
char *actor = xs_dict_get(q_item, "actor");
|
char *actor = xs_dict_get(q_item, "actor");
|
||||||
char *msg = xs_dict_get(q_item, "object");
|
char *msg = xs_dict_get(q_item, "object");
|
||||||
int retries = xs_number_get(xs_dict_get(q_item, "retries"));
|
int retries = xs_number_get(xs_dict_get(q_item, "retries"));
|
||||||
|
xs *payload = NULL;
|
||||||
|
int p_size = 0;
|
||||||
|
|
||||||
/* deliver */
|
/* deliver */
|
||||||
status = send_to_actor(snac, actor, msg, NULL, 0);
|
status = send_to_actor(snac, actor, msg, &payload, &p_size);
|
||||||
|
|
||||||
if (!valid_status(status)) {
|
if (!valid_status(status)) {
|
||||||
/* error sending; reenqueue? */
|
/* error sending; reenqueue? */
|
||||||
|
@ -420,12 +431,14 @@ d_char *recipient_list(snac *snac, char *msg, int expand_public)
|
||||||
|
|
||||||
char *p = fwers;
|
char *p = fwers;
|
||||||
while (xs_list_iter(&p, &fw)) {
|
while (xs_list_iter(&p, &fw)) {
|
||||||
if (!xs_list_in(list, fw))
|
char *actor = xs_dict_get(fw, "actor");
|
||||||
list = xs_list_append(list, fw);
|
|
||||||
|
if (xs_list_in(list, actor) == -1)
|
||||||
|
list = xs_list_append(list, actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (!xs_list_in(list, v))
|
if (xs_list_in(list, v) == -1)
|
||||||
list = xs_list_append(list, v);
|
list = xs_list_append(list, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
data.c
6
data.c
|
@ -302,8 +302,8 @@ int timeline_here(snac *snac, char *id)
|
||||||
d_char *timeline_find(snac *snac, char *id)
|
d_char *timeline_find(snac *snac, char *id)
|
||||||
/* gets a message from the timeline by id */
|
/* gets a message from the timeline by id */
|
||||||
{
|
{
|
||||||
xs *fn = _timeline_find_fn(snac, id);
|
xs *fn = _timeline_find_fn(snac, id);
|
||||||
xs *msg = NULL;
|
d_char *msg = NULL;
|
||||||
|
|
||||||
if (fn != NULL) {
|
if (fn != NULL) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -820,7 +820,7 @@ void enqueue_output(snac *snac, char *msg, char *actor, int retries)
|
||||||
return;
|
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 *ntid = tid(retries * 60 * qrt);
|
||||||
xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
|
xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
|
||||||
xs *tfn = xs_fmt("%s.tmp", fn);
|
xs *tfn = xs_fmt("%s.tmp", fn);
|
||||||
|
|
2
httpd.c
2
httpd.c
|
@ -97,7 +97,7 @@ void httpd_connection(int rs)
|
||||||
xs *headers = NULL;
|
xs *headers = NULL;
|
||||||
xs *q_path = NULL;
|
xs *q_path = NULL;
|
||||||
xs *payload = NULL;
|
xs *payload = NULL;
|
||||||
int p_size;
|
int p_size = 0;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
f = xs_socket_accept(rs);
|
f = xs_socket_accept(rs);
|
||||||
|
|
4
main.c
4
main.c
|
@ -119,7 +119,9 @@ int main(int argc, char *argv[])
|
||||||
if (strcmp(cmd, "announce") == 0) {
|
if (strcmp(cmd, "announce") == 0) {
|
||||||
xs *msg = msg_admiration(&snac, url, "Announce");
|
xs *msg = msg_admiration(&snac, url, "Announce");
|
||||||
|
|
||||||
{
|
if (msg != NULL) {
|
||||||
|
post(&snac, msg);
|
||||||
|
|
||||||
xs *j = xs_json_dumps_pp(msg, 4);
|
xs *j = xs_json_dumps_pp(msg, 4);
|
||||||
printf("%s\n", j);
|
printf("%s\n", j);
|
||||||
}
|
}
|
||||||
|
|
12
snac.c
12
snac.c
|
@ -142,7 +142,7 @@ void srv_archive(char *direction, char *req, char *payload, int p_size,
|
||||||
/* archives a connection */
|
/* archives a connection */
|
||||||
{
|
{
|
||||||
/* obsessive archiving */
|
/* 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);
|
xs *dir = xs_fmt("%s/archive/%s", srv_basedir, date);
|
||||||
FILE *f;
|
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) {
|
if ((f = fopen(payload_fn, "w")) != NULL) {
|
||||||
xs *v1 = xs_json_loads(payload);
|
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)
|
if (j1 != NULL)
|
||||||
fwrite(j1, strlen(j1), 1, f);
|
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) {
|
if ((f = fopen(body_fn, "w")) != NULL) {
|
||||||
xs *v1 = xs_json_loads(body);
|
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)
|
if (j1 != NULL)
|
||||||
fwrite(j1, strlen(j1), 1, f);
|
fwrite(j1, strlen(j1), 1, f);
|
||||||
|
|
1
snac.h
1
snac.h
|
@ -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_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);
|
int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size);
|
||||||
void process_queue(snac *snac);
|
void process_queue(snac *snac);
|
||||||
|
void post(snac *snac, char *msg);
|
||||||
int activitypub_get_handler(d_char *req, char *q_path,
|
int activitypub_get_handler(d_char *req, char *q_path,
|
||||||
char **body, int *b_size, char **ctype);
|
char **body, int *b_size, char **ctype);
|
||||||
int activitypub_post_handler(d_char *req, char *q_path,
|
int activitypub_post_handler(d_char *req, char *q_path,
|
||||||
|
|
Loading…
Reference in a new issue