summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-08-21 22:49:46 +0200
committerdefault <nobody@localhost>2023-08-21 22:49:46 +0200
commit1d00c4ef66060a185452f83ecf639e6d3a49baf5 (patch)
treedce4449d170740627588a34d4c749b71b6e4a2d9
parent3495c69b35d8d5ab49290cd26ffad20ac7c21dd2 (diff)
The nodeinfo file returns more useful information.
-rw-r--r--httpd.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/httpd.c b/httpd.c
index 5f24685..52684cf 100644
--- a/httpd.c
+++ b/httpd.c
@@ -39,11 +39,35 @@ const char *nodeinfo_2_0_template = ""
xs_str *nodeinfo_2_0(void)
/* builds a nodeinfo json object */
{
- xs *users = user_list();
- int n_users = xs_list_len(users);
- int n_posts = 0; /* to be implemented someday */
+ int n_utotal = 0;
+ int n_umonth = 0;
+ int n_uhyear = 0;
+ int n_posts = 0;
+ xs *users = user_list();
+ xs_list *p;
+ char *v;
+
+ p = users;
+ while (xs_list_iter(&p, &v)) {
+ /* build the full path name to the last usage log */
+ xs *llfn = xs_fmt("%s/user/%s/lastlog.txt", srv_basedir, v);
+ double llsecs = (double)time(NULL) - mtime(llfn);
+
+ if (llsecs < 60 * 60 * 24 * 30 * 6) {
+ n_uhyear++;
+
+ if (llsecs < 60 * 60 * 24 * 30)
+ n_umonth++;
+ }
+
+ n_utotal++;
+
+ /* build the file to each user public.idx */
+ xs *pidxfn = xs_fmt("%s/user/%s/private.idx", srv_basedir, v);
+ n_posts += index_len(pidxfn);
+ }
- return xs_fmt(nodeinfo_2_0_template, n_users, n_users, n_users, n_posts);
+ return xs_fmt(nodeinfo_2_0_template, n_utotal, n_umonth, n_uhyear, n_posts);
}