New function msg_admiration().

This commit is contained in:
default 2022-09-26 10:08:14 +02:00
parent f410e3a40a
commit acc467c034
4 changed files with 34 additions and 1 deletions

View File

@ -191,6 +191,26 @@ 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();
/* call the object */
timeline_request(snac, object, snac->actor);
rcpts = xs_list_append(rcpts, public_address);
msg = xs_dict_append(msg, "to", rcpts);
msg = xs_dict_append(msg, "object", object);
return msg;
}
d_char *msg_actor(snac *snac)
/* create a Person message for this actor */
{

2
data.c
View File

@ -554,7 +554,7 @@ int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer
md = xs_dict_set(md, "parent", parent);
if (!xs_is_null(referrer))
md = xs_dict_set(md, "parent", referrer);
md = xs_dict_set(md, "referrer", referrer);
msg = xs_dict_set(msg, "_snac", md);

11
main.c
View File

@ -116,6 +116,17 @@ int main(int argc, char *argv[])
if ((url = GET_ARGV()) == NULL)
return usage();
if (strcmp(cmd, "announce") == 0) {
xs *msg = msg_admiration(&snac, url, "Announce");
{
xs *j = xs_json_dumps_pp(msg, 4);
printf("%s\n", j);
}
return 0;
}
if (strcmp(cmd, "request") == 0) {
int status;
xs *data = NULL;

2
snac.h
View File

@ -87,6 +87,8 @@ int webfinger_request(char *qs, char **actor, char **user);
int webfinger_get_handler(d_char *req, char *q_path,
char **body, int *b_size, char **ctype);
d_char *msg_admiration(snac *snac, char *object, char *type);
int activitypub_request(snac *snac, char *url, d_char **data);
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);