summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c
index 2b73f56..a5e23de 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -924,6 +924,39 @@ xs_dict *msg_pong(snac *user, const char *rcpt, const char *object)
924} 924}
925 925
926 926
927xs_dict *msg_question(snac *user, const char *content, const xs_list *opts, int multiple, int end_secs)
928/* creates a Question message */
929{
930 xs *ntid = tid(0);
931 xs *id = xs_fmt("%s/q/%s", user->actor, ntid);
932 xs_dict *msg = msg_base(user, "Question", id, NULL, "@now", NULL);
933
934 msg = xs_dict_append(msg, "content", content);
935 msg = xs_dict_append(msg, "attributedTo", user->actor);
936
937 xs *o = xs_list_new();
938 xs_list *p = (xs_list *)opts;
939 xs_str *v;
940
941 while (xs_list_iter(&p, &v)) {
942 xs *d = xs_dict_new();
943
944 d = xs_dict_append(d, "name", v);
945 o = xs_list_append(o, d);
946 }
947
948 msg = xs_dict_append(msg, multiple ? "anyOf" : "oneOf", o);
949
950 /* set the end time */
951 time_t t = time(NULL) + end_secs;
952 xs *et = xs_str_utctime(t, "%Y-%m-%dT%H:%M:%SZ");
953
954 msg = xs_dict_append(msg, "endTime", msg);
955
956 return msg;
957}
958
959
927void notify(snac *snac, xs_str *type, xs_str *utype, xs_str *actor, xs_dict *msg) 960void notify(snac *snac, xs_str *type, xs_str *utype, xs_str *actor, xs_dict *msg)
928/* notifies the user of relevant events */ 961/* notifies the user of relevant events */
929{ 962{