diff options
| author | 2023-05-24 11:07:47 +0200 | |
|---|---|---|
| committer | 2023-05-24 11:07:47 +0200 | |
| commit | 9bc48255071016a124807a7fc6a7316c3abe734a (patch) | |
| tree | 1c5d2b41b6dbcc7ffa93d9e362953d450c8a2d3b /activitypub.c | |
| parent | Call timeline_touch() on successful 'Update' messages. (diff) | |
| download | snac2-9bc48255071016a124807a7fc6a7316c3abe734a.tar.gz snac2-9bc48255071016a124807a7fc6a7316c3abe734a.tar.xz snac2-9bc48255071016a124807a7fc6a7316c3abe734a.zip | |
New function msg_question() (unused).
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 33 |
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 | ||
| 927 | xs_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 | |||
| 927 | void notify(snac *snac, xs_str *type, xs_str *utype, xs_str *actor, xs_dict *msg) | 960 | void 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 | { |