mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-26 06:53:37 +00:00
actor_get() returns an actor message for local users.
This commit is contained in:
parent
ede4d6f2dc
commit
e31c4810a8
1 changed files with 21 additions and 5 deletions
26
data.c
26
data.c
|
@ -1287,27 +1287,43 @@ int is_hidden(snac *snac, const char *id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int actor_add(snac *snac, const char *actor, d_char *msg)
|
int actor_add(snac *snac, const char *actor, xs_dict *msg)
|
||||||
/* adds an actor */
|
/* adds an actor */
|
||||||
{
|
{
|
||||||
return object_add_ow(actor, msg);
|
return object_add_ow(actor, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int actor_get(snac *snac, const char *actor, d_char **data)
|
int actor_get(snac *snac1, const char *actor, xs_dict **data)
|
||||||
/* returns an already downloaded actor */
|
/* returns an already downloaded actor */
|
||||||
{
|
{
|
||||||
int status = 200;
|
int status = 200;
|
||||||
d_char *d;
|
xs_dict *d;
|
||||||
|
|
||||||
if (strcmp(actor, snac->actor) == 0) {
|
if (strcmp(actor, snac1->actor) == 0) {
|
||||||
/* this actor */
|
/* this actor */
|
||||||
if (data)
|
if (data)
|
||||||
*data = msg_actor(snac);
|
*data = msg_actor(snac1);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xs_startswith(actor, srv_baseurl)) {
|
||||||
|
/* it's a (possible) local user */
|
||||||
|
xs *l = xs_split(actor, "/");
|
||||||
|
const char *uid = xs_list_get(l, -1);
|
||||||
|
snac user;
|
||||||
|
|
||||||
|
if (!xs_is_null(uid) && user_open(&user, uid)) {
|
||||||
|
if (data)
|
||||||
|
*data = msg_actor(&user);
|
||||||
|
|
||||||
|
user_free(&user);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
|
||||||
/* read the object */
|
/* read the object */
|
||||||
if (!valid_status(status = object_get(actor, &d)))
|
if (!valid_status(status = object_get(actor, &d)))
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Reference in a new issue