diff --git a/activitypub.c b/activitypub.c index 09fa55e..f19774c 100644 --- a/activitypub.c +++ b/activitypub.c @@ -399,7 +399,7 @@ d_char *msg_admiration(snac *snac, char *object, char *type) /* call the object */ timeline_request(snac, object, snac->actor); - if ((a_msg = timeline_find(snac, object)) != NULL) { + if (valid_status(object_get(object, &a_msg, NULL))) { xs *rcpts = xs_list_new(); msg = msg_base(snac, type, "@dummy", snac->actor, "@now", object); @@ -592,7 +592,7 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char /* demand this thing */ timeline_request(snac, in_reply_to, NULL); - if ((p_msg = timeline_find(snac, in_reply_to)) != NULL) { + if (valid_status(object_get(in_reply_to, &p_msg, NULL))) { /* add this author as recipient */ char *a, *v; @@ -892,7 +892,7 @@ int process_message(snac *snac, char *msg, char *req) timeline_request(snac, object, actor); - if ((a_msg = timeline_find(snac, object)) != NULL) { + if (valid_status(object_get(object, &a_msg, NULL))) { char *who = xs_dict_get(a_msg, "attributedTo"); if (who && !is_muted(snac, who)) { diff --git a/data.c b/data.c index a530f22..aee03e2 100644 --- a/data.c +++ b/data.c @@ -738,56 +738,11 @@ d_char *follower_list(snac *snac) double timeline_mtime(snac *snac) { - xs *fn = xs_fmt("%s/timeline", snac->basedir); + xs *fn = xs_fmt("%s/private.idx", snac->basedir); return mtime(fn); } -d_char *_timeline_find_fn(snac *snac, char *id) -/* returns the file name of a timeline entry by its id */ -{ - xs *md5 = xs_md5_hex(id, strlen(id)); - xs *spec = xs_fmt("%s/timeline/" "*-%s.json", snac->basedir, md5); - xs *list = NULL; - d_char *fn = NULL; - int l; - - list = xs_glob(spec, 0, 0); - l = xs_list_len(list); - - /* if there is something, get the first one */ - if (l > 0) { - fn = xs_str_new(xs_list_get(list, 0)); - - if (l > 1) - snac_log(snac, xs_fmt("**ALERT** _timeline_find_fn %d > 1", l)); - } - - return fn; -} - - -d_char *timeline_find(snac *snac, char *id) -/* gets a message from the timeline by id */ -{ - xs *fn = _timeline_find_fn(snac, id); - d_char *msg = NULL; - - if (fn != NULL) { - FILE *f; - - if ((f = fopen(fn, "r")) != NULL) { - xs *j = xs_readall(f); - - msg = xs_json_loads(j); - fclose(f); - } - } - - return msg; -} - - int timeline_del(snac *snac, char *id) /* deletes a message from the timeline */ { @@ -800,16 +755,6 @@ int timeline_del(snac *snac, char *id) } -d_char *_timeline_new_fn(snac *snac, char *id) -/* creates a new filename */ -{ - xs *ntid = tid(0); - xs *md5 = xs_md5_hex(id, strlen(id)); - - return xs_fmt("%s/timeline/%s-%s.json", snac->basedir, ntid, md5); -} - - void timeline_update_indexes(snac *snac, const char *id) /* updates the indexes */ { diff --git a/snac.h b/snac.h index e4a73d8..3d7d8fd 100644 --- a/snac.h +++ b/snac.h @@ -76,8 +76,6 @@ int follower_check(snac *snac, const char *actor); d_char *follower_list(snac *snac); double timeline_mtime(snac *snac); -d_char *_timeline_find_fn(snac *snac, char *id); -d_char *timeline_find(snac *snac, char *id); int timeline_del(snac *snac, char *id); d_char *timeline_list(snac *snac, const char *idx_name, int max); int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer);