mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
Added a working space to timeline_request().
This commit is contained in:
parent
e762d942de
commit
850259b269
@ -78,7 +78,7 @@ int actor_request(snac *snac, char *actor, d_char **data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int timeline_request(snac *snac, char **id, char *referrer)
|
int timeline_request(snac *snac, char **id, char *referrer, d_char **wrk)
|
||||||
/* ensures that an entry and its ancestors are in the timeline */
|
/* ensures that an entry and its ancestors are in the timeline */
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
@ -97,12 +97,12 @@ int timeline_request(snac *snac, char **id, char *referrer)
|
|||||||
/* get the id again from the object, as it may be different */
|
/* get the id again from the object, as it may be different */
|
||||||
char *nid = xs_dict_get(object, "id");
|
char *nid = xs_dict_get(object, "id");
|
||||||
|
|
||||||
if (strcmp(nid, *id) != 0) {
|
if (wrk && strcmp(nid, *id) != 0) {
|
||||||
snac_debug(snac, 1,
|
snac_debug(snac, 1,
|
||||||
xs_fmt("timeline_request canonical id for %s is %s", *id, nid));
|
xs_fmt("timeline_request canonical id for %s is %s", *id, nid));
|
||||||
|
|
||||||
/* FIXME: nid points inside a dynamic block */
|
*wrk = xs_dup(nid);
|
||||||
*id = nid;
|
*id = *wrk;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xs_is_null(type) && strcmp(type, "Note") == 0) {
|
if (!xs_is_null(type) && strcmp(type, "Note") == 0) {
|
||||||
@ -116,7 +116,7 @@ int timeline_request(snac *snac, char **id, char *referrer)
|
|||||||
char *in_reply_to = xs_dict_get(object, "inReplyTo");
|
char *in_reply_to = xs_dict_get(object, "inReplyTo");
|
||||||
|
|
||||||
/* recurse! */
|
/* recurse! */
|
||||||
timeline_request(snac, &in_reply_to, referrer);
|
timeline_request(snac, &in_reply_to, referrer, NULL);
|
||||||
|
|
||||||
/* finally store */
|
/* finally store */
|
||||||
timeline_add(snac, *id, object, in_reply_to, referrer);
|
timeline_add(snac, *id, object, in_reply_to, referrer);
|
||||||
@ -419,9 +419,10 @@ d_char *msg_admiration(snac *snac, char *object, char *type)
|
|||||||
{
|
{
|
||||||
xs *a_msg = NULL;
|
xs *a_msg = NULL;
|
||||||
d_char *msg = NULL;
|
d_char *msg = NULL;
|
||||||
|
xs *wrk = NULL;
|
||||||
|
|
||||||
/* call the object */
|
/* call the object */
|
||||||
timeline_request(snac, &object, snac->actor);
|
timeline_request(snac, &object, snac->actor, &wrk);
|
||||||
|
|
||||||
if (valid_status(object_get(object, &a_msg, NULL))) {
|
if (valid_status(object_get(object, &a_msg, NULL))) {
|
||||||
xs *rcpts = xs_list_new();
|
xs *rcpts = xs_list_new();
|
||||||
@ -612,9 +613,10 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
|
|||||||
|
|
||||||
if (in_reply_to != NULL && *in_reply_to) {
|
if (in_reply_to != NULL && *in_reply_to) {
|
||||||
xs *p_msg = NULL;
|
xs *p_msg = NULL;
|
||||||
|
xs *wrk = NULL;
|
||||||
|
|
||||||
/* demand this thing */
|
/* demand this thing */
|
||||||
timeline_request(snac, &in_reply_to, NULL);
|
timeline_request(snac, &in_reply_to, NULL, &wrk);
|
||||||
|
|
||||||
if (valid_status(object_get(in_reply_to, &p_msg, NULL))) {
|
if (valid_status(object_get(in_reply_to, &p_msg, NULL))) {
|
||||||
/* add this author as recipient */
|
/* add this author as recipient */
|
||||||
@ -886,8 +888,9 @@ int process_message(snac *snac, char *msg, char *req)
|
|||||||
else {
|
else {
|
||||||
char *id = xs_dict_get(object, "id");
|
char *id = xs_dict_get(object, "id");
|
||||||
char *in_reply_to = xs_dict_get(object, "inReplyTo");
|
char *in_reply_to = xs_dict_get(object, "inReplyTo");
|
||||||
|
xs *wrk = NULL;
|
||||||
|
|
||||||
timeline_request(snac, &in_reply_to, NULL);
|
timeline_request(snac, &in_reply_to, NULL, &wrk);
|
||||||
|
|
||||||
if (timeline_add(snac, id, object, in_reply_to, NULL)) {
|
if (timeline_add(snac, id, object, in_reply_to, NULL)) {
|
||||||
snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
|
snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
|
||||||
@ -923,11 +926,12 @@ int process_message(snac *snac, char *msg, char *req)
|
|||||||
else
|
else
|
||||||
if (strcmp(type, "Announce") == 0) {
|
if (strcmp(type, "Announce") == 0) {
|
||||||
xs *a_msg = NULL;
|
xs *a_msg = NULL;
|
||||||
|
xs *wrk = NULL;
|
||||||
|
|
||||||
if (xs_type(object) == XSTYPE_DICT)
|
if (xs_type(object) == XSTYPE_DICT)
|
||||||
object = xs_dict_get(object, "id");
|
object = xs_dict_get(object, "id");
|
||||||
|
|
||||||
timeline_request(snac, &object, actor);
|
timeline_request(snac, &object, actor, &wrk);
|
||||||
|
|
||||||
if (valid_status(object_get(object, &a_msg, NULL))) {
|
if (valid_status(object_get(object, &a_msg, NULL))) {
|
||||||
char *who = xs_dict_get(a_msg, "attributedTo");
|
char *who = xs_dict_get(a_msg, "attributedTo");
|
||||||
|
Loading…
Reference in New Issue
Block a user