diff options
| author | default <nobody@localhost> | 2022-09-25 09:07:43 +0200 |
|---|---|---|
| committer | default <nobody@localhost> | 2022-09-25 09:07:43 +0200 |
| commit | 4f328eec1f428d4e87adeb4c4eaf1e81afe26913 (patch) | |
| tree | a3636038d0347efb593f1bf580fbe67d3ab0bed1 /data.c | |
| parent | 5792ef5d24bd58f5c74a37c43d80720c46a6758a (diff) | |
Some fixes to timeline_add().
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -391,7 +391,7 @@ d_char *_timeline_new_fn(snac *snac, char *id) } -void timeline_add(snac *snac, char *id, char *msg, char *parent) +void timeline_add(snac *snac, char *id, char *o_msg, char *parent) /* adds a message to the timeline */ { xs *pfn = _timeline_find_fn(snac, id); @@ -404,6 +404,7 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent) /* build the new filename */ xs *fn = _timeline_new_fn(snac, id); + xs *msg = xs_dup(o_msg); xs *md; /* add metadata */ @@ -414,7 +415,7 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent) "\"parent\": null" "}"); - if (parent != NULL) + if (!xs_is_null(parent)) md = xs_dict_set(md, "parent", parent); msg = xs_dict_set(msg, "_snac", md); @@ -430,14 +431,14 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent) /* related to this user? link to local timeline */ if (xs_startswith(id, snac->actor) || - (parent != NULL && xs_startswith(parent, snac->actor))) { + (!xs_is_null(parent) && xs_startswith(parent, snac->actor))) { xs *lfn = xs_replace(fn, "/timeline/", "/local/"); link(fn, lfn); snac_debug(snac, 1, xs_fmt("timeline_add (local) %s %s", id, lfn)); } - if (parent != NULL) { + if (!xs_is_null(parent)) { /* update the parent, adding this id to its children list */ xs *pfn = _timeline_find_fn(snac, parent); xs *p_msg = NULL; @@ -493,7 +494,7 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent) /* now iterate all parents up, just renaming the files */ xs *grampa = xs_dup(xs_dict_get(meta, "parent")); - while (grampa != NULL) { + while (!xs_is_null(grampa)) { xs *gofn = _timeline_find_fn(snac, grampa); if (gofn == NULL) @@ -528,7 +529,7 @@ void timeline_add(snac *snac, char *id, char *msg, char *parent) free(grampa); - if (p != NULL) + if (!xs_is_null(p)) p = xs_dup(p); grampa = p; |