mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
New function msg_question() (unused).
This commit is contained in:
parent
50fe76edd2
commit
9bc4825507
2 changed files with 34 additions and 0 deletions
|
@ -924,6 +924,39 @@ xs_dict *msg_pong(snac *user, const char *rcpt, const char *object)
|
|||
}
|
||||
|
||||
|
||||
xs_dict *msg_question(snac *user, const char *content, const xs_list *opts, int multiple, int end_secs)
|
||||
/* creates a Question message */
|
||||
{
|
||||
xs *ntid = tid(0);
|
||||
xs *id = xs_fmt("%s/q/%s", user->actor, ntid);
|
||||
xs_dict *msg = msg_base(user, "Question", id, NULL, "@now", NULL);
|
||||
|
||||
msg = xs_dict_append(msg, "content", content);
|
||||
msg = xs_dict_append(msg, "attributedTo", user->actor);
|
||||
|
||||
xs *o = xs_list_new();
|
||||
xs_list *p = (xs_list *)opts;
|
||||
xs_str *v;
|
||||
|
||||
while (xs_list_iter(&p, &v)) {
|
||||
xs *d = xs_dict_new();
|
||||
|
||||
d = xs_dict_append(d, "name", v);
|
||||
o = xs_list_append(o, d);
|
||||
}
|
||||
|
||||
msg = xs_dict_append(msg, multiple ? "anyOf" : "oneOf", o);
|
||||
|
||||
/* set the end time */
|
||||
time_t t = time(NULL) + end_secs;
|
||||
xs *et = xs_str_utctime(t, "%Y-%m-%dT%H:%M:%SZ");
|
||||
|
||||
msg = xs_dict_append(msg, "endTime", msg);
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
void notify(snac *snac, xs_str *type, xs_str *utype, xs_str *actor, xs_dict *msg)
|
||||
/* notifies the user of relevant events */
|
||||
{
|
||||
|
|
1
snac.h
1
snac.h
|
@ -205,6 +205,7 @@ d_char *msg_actor(snac *snac);
|
|||
xs_dict *msg_update(snac *snac, xs_dict *object);
|
||||
xs_dict *msg_ping(snac *user, const char *rcpt);
|
||||
xs_dict *msg_pong(snac *user, const char *rcpt, const char *object);
|
||||
xs_dict *msg_question(snac *user, const char *content, const xs_list *opts, int multiple, int end_secs);
|
||||
|
||||
int activitypub_request(snac *snac, const char *url, xs_dict **data);
|
||||
int actor_request(snac *snac, const char *actor, xs_dict **data);
|
||||
|
|
Loading…
Reference in a new issue