diff options
| author | 2025-04-01 06:32:53 +0200 | |
|---|---|---|
| committer | 2025-04-01 06:32:53 +0200 | |
| commit | 9b2d0381ba734102c20d2111f0a2b64a3c438ef7 (patch) | |
| tree | d969b47e718d7efe53fafe648a363a198a01e4f3 /data.c | |
| parent | Added more scheduling code. (diff) | |
| download | penes-snac2-9b2d0381ba734102c20d2111f0a2b64a3c438ef7.tar.gz penes-snac2-9b2d0381ba734102c20d2111f0a2b64a3c438ef7.tar.xz penes-snac2-9b2d0381ba734102c20d2111f0a2b64a3c438ef7.zip | |
More scheduled post code.
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 29 |
1 files changed, 28 insertions, 1 deletions
| @@ -1966,6 +1966,33 @@ xs_list *scheduled_list(snac *user) | |||
| 1966 | } | 1966 | } |
| 1967 | 1967 | ||
| 1968 | 1968 | ||
| 1969 | void scheduled_process(snac *user) | ||
| 1970 | /* processes the scheduled list, sending those ready to be sent */ | ||
| 1971 | { | ||
| 1972 | xs *posts = scheduled_list(user); | ||
| 1973 | const char *md5; | ||
| 1974 | xs *right_now = xs_str_utctime(0, ISO_DATE_SPEC); | ||
| 1975 | |||
| 1976 | xs_list_foreach(posts, md5) { | ||
| 1977 | xs *msg = NULL; | ||
| 1978 | |||
| 1979 | if (valid_status(object_get_by_md5(md5, &msg))) { | ||
| 1980 | if (strcmp(xs_dict_get(msg, "published"), right_now) < 0) { | ||
| 1981 | /* due date! */ | ||
| 1982 | const char *id = xs_dict_get(msg, "id"); | ||
| 1983 | |||
| 1984 | timeline_add(user, id, msg); | ||
| 1985 | |||
| 1986 | xs *c_msg = msg_create(user, msg); | ||
| 1987 | enqueue_message(user, c_msg); | ||
| 1988 | |||
| 1989 | schedule_del(user, id); | ||
| 1990 | } | ||
| 1991 | } | ||
| 1992 | } | ||
| 1993 | } | ||
| 1994 | |||
| 1995 | |||
| 1969 | /** hiding **/ | 1996 | /** hiding **/ |
| 1970 | 1997 | ||
| 1971 | xs_str *_hidden_fn(snac *snac, const char *id) | 1998 | xs_str *_hidden_fn(snac *snac, const char *id) |
| @@ -3734,7 +3761,7 @@ void purge_user(snac *snac) | |||
| 3734 | _purge_user_subdir(snac, "public", pub_days); | 3761 | _purge_user_subdir(snac, "public", pub_days); |
| 3735 | 3762 | ||
| 3736 | const char *idxs[] = { "followers.idx", "private.idx", "public.idx", | 3763 | const char *idxs[] = { "followers.idx", "private.idx", "public.idx", |
| 3737 | "pinned.idx", "bookmark.idx", "draft.idx", NULL }; | 3764 | "pinned.idx", "bookmark.idx", "draft.idx", "sched.idx", NULL }; |
| 3738 | 3765 | ||
| 3739 | for (n = 0; idxs[n]; n++) { | 3766 | for (n = 0; idxs[n]; n++) { |
| 3740 | xs *idx = xs_fmt("%s/%s", snac->basedir, idxs[n]); | 3767 | xs *idx = xs_fmt("%s/%s", snac->basedir, idxs[n]); |