1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* snac - A simple, minimalistic ActivityPub instance */
/* copyright (c) 2022 grunfink - MIT license */
#include "xs.h"
#include "xs_encdec.h"
#include "xs_json.h"
#include "xs_curl.h"
#include "snac.h"
const char *public_address = "https:/" "/www.w3.org/ns/activitystreams#Public";
int activitypub_request(snac *snac, char *url, d_char **data)
/* request an object */
{
int status;
xs *response = NULL;
xs *payload;
int p_size;
/* check if it's an url for this same site */
/* ... */
/* get from the net */
response = http_signed_request(snac, "GET", url,
NULL, NULL, 0, &status, &payload, &p_size);
{
xs *j = xs_json_loads(response);
printf("%s\n", j);
}
if (valid_status(status)) {
*data = xs_json_loads(payload);
}
return status;
}
#if 0
int actor_request(snac *snac, char *actor, d_char **data)
/* request an actor */
{
int status;
xs *response = NULL;
xs *payload;
int p_size;
/* get from disk first */
status = actor_get(snac, actor, data);
if (status == 200)
return;
/* get from the net */
response = http_signed_request(snac, "GET", actor,
NULL, NULL, 0, &status, &payload, &p_size);
// response = http_signed_request(&snac, "GET", "https://mastodon.social/users/VictorMoral",
// headers, NULL, 0, &status, &payload, &p_size);
return status;
}
#endif
|