summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
Diffstat (limited to 'data.c')
-rw-r--r--data.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/data.c b/data.c
index c3576cc..0b87c6a 100644
--- a/data.c
+++ b/data.c
@@ -391,7 +391,7 @@ d_char *_timeline_new_fn(snac *snac, char *id)
391} 391}
392 392
393 393
394void timeline_add(snac *snac, char *id, char *msg, char *parent) 394void timeline_add(snac *snac, char *id, char *o_msg, char *parent)
395/* adds a message to the timeline */ 395/* adds a message to the timeline */
396{ 396{
397 xs *pfn = _timeline_find_fn(snac, id); 397 xs *pfn = _timeline_find_fn(snac, id);
@@ -404,6 +404,7 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent)
404 404
405 /* build the new filename */ 405 /* build the new filename */
406 xs *fn = _timeline_new_fn(snac, id); 406 xs *fn = _timeline_new_fn(snac, id);
407 xs *msg = xs_dup(o_msg);
407 xs *md; 408 xs *md;
408 409
409 /* add metadata */ 410 /* add metadata */
@@ -414,7 +415,7 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent)
414 "\"parent\": null" 415 "\"parent\": null"
415 "}"); 416 "}");
416 417
417 if (parent != NULL) 418 if (!xs_is_null(parent))
418 md = xs_dict_set(md, "parent", parent); 419 md = xs_dict_set(md, "parent", parent);
419 420
420 msg = xs_dict_set(msg, "_snac", md); 421 msg = xs_dict_set(msg, "_snac", md);
@@ -430,14 +431,14 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent)
430 431
431 /* related to this user? link to local timeline */ 432 /* related to this user? link to local timeline */
432 if (xs_startswith(id, snac->actor) || 433 if (xs_startswith(id, snac->actor) ||
433 (parent != NULL && xs_startswith(parent, snac->actor))) { 434 (!xs_is_null(parent) && xs_startswith(parent, snac->actor))) {
434 xs *lfn = xs_replace(fn, "/timeline/", "/local/"); 435 xs *lfn = xs_replace(fn, "/timeline/", "/local/");
435 link(fn, lfn); 436 link(fn, lfn);
436 437
437 snac_debug(snac, 1, xs_fmt("timeline_add (local) %s %s", id, lfn)); 438 snac_debug(snac, 1, xs_fmt("timeline_add (local) %s %s", id, lfn));
438 } 439 }
439 440
440 if (parent != NULL) { 441 if (!xs_is_null(parent)) {
441 /* update the parent, adding this id to its children list */ 442 /* update the parent, adding this id to its children list */
442 xs *pfn = _timeline_find_fn(snac, parent); 443 xs *pfn = _timeline_find_fn(snac, parent);
443 xs *p_msg = NULL; 444 xs *p_msg = NULL;
@@ -493,7 +494,7 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent)
493 /* now iterate all parents up, just renaming the files */ 494 /* now iterate all parents up, just renaming the files */
494 xs *grampa = xs_dup(xs_dict_get(meta, "parent")); 495 xs *grampa = xs_dup(xs_dict_get(meta, "parent"));
495 496
496 while (grampa != NULL) { 497 while (!xs_is_null(grampa)) {
497 xs *gofn = _timeline_find_fn(snac, grampa); 498 xs *gofn = _timeline_find_fn(snac, grampa);
498 499
499 if (gofn == NULL) 500 if (gofn == NULL)
@@ -528,7 +529,7 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent)
528 529
529 free(grampa); 530 free(grampa);
530 531
531 if (p != NULL) 532 if (!xs_is_null(p))
532 p = xs_dup(p); 533 p = xs_dup(p);
533 534
534 grampa = p; 535 grampa = p;