snac2/main.c

78 lines
1.5 KiB
C
Raw Normal View History

2022-09-19 19:32:36 +00:00
/* snac - A simple, minimalistic ActivityPub instance */
/* copyright (c) 2022 grunfink - MIT license */
#include "xs.h"
#include "snac.h"
int main(int argc, char *argv[])
{
snac snac;
2022-09-20 10:00:13 +00:00
printf("%s\n", tid(0));
2022-09-20 07:39:28 +00:00
srv_open("/home/angel/lib/snac/comam.es/");
2022-09-19 19:32:36 +00:00
2022-09-19 21:03:18 +00:00
user_open(&snac, "mike");
2022-09-20 07:48:13 +00:00
xs *headers = xs_dict_new();
int status;
d_char *payload;
int p_size;
http_signed_request(&snac, "GET", "https://comam.es/snac/jessie",
headers, NULL, 0, &status, &payload, &p_size);
2022-09-20 10:43:49 +00:00
{
xs *list = queue(&snac);
char *p, *fn;
p = list;
while (xs_list_iter(&p, &fn)) {
2022-09-20 10:50:37 +00:00
xs *obj;
obj = dequeue(&snac, fn);
printf("%s\n", xs_dict_get(obj, "actor"));
2022-09-20 10:43:49 +00:00
}
}
#if 0
2022-09-20 07:48:13 +00:00
{
xs *list = follower_list(&snac);
char *p, *obj;
p = list;
while (xs_list_iter(&p, &obj)) {
char *actor = xs_dict_get(obj, "actor");
printf("%s\n", actor);
}
}
2022-09-20 08:49:24 +00:00
{
xs *list = timeline_list(&snac);
char *p, *fn;
p = list;
while (xs_list_iter(&p, &fn)) {
xs *tle = timeline_get(&snac, fn);
printf("%s\n", xs_dict_get(tle, "id"));
}
}
2022-09-19 21:33:11 +00:00
{
xs *list = user_list();
char *p, *uid;
p = list;
while (xs_list_iter(&p, &uid)) {
2022-09-20 07:39:28 +00:00
if (user_open(&snac, uid)) {
printf("%s (%s)\n", uid, xs_dict_get(snac.config, "name"));
user_free(&snac);
}
2022-09-19 21:33:11 +00:00
}
}
2022-09-20 10:43:49 +00:00
#endif
2022-09-19 21:33:11 +00:00
2022-09-19 19:32:36 +00:00
return 0;
}