diff options
| author | 2024-07-24 18:31:49 +0200 | |
|---|---|---|
| committer | 2024-07-24 18:31:49 +0200 | |
| commit | 7a20b14fbcc169833190e03a5964944e0dcd9e65 (patch) | |
| tree | aa774822ee9139b7088a8a4ae42f9a6fcba48cde /mastoapi.c | |
| parent | Use MD5_HEX_SIZE in more places. (diff) | |
| download | snac2-7a20b14fbcc169833190e03a5964944e0dcd9e65.tar.gz snac2-7a20b14fbcc169833190e03a5964944e0dcd9e65.tar.xz snac2-7a20b14fbcc169833190e03a5964944e0dcd9e65.zip | |
mastoapi: opening a token file updates its file date and its app's.
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 13 |
1 files changed, 13 insertions, 0 deletions
| @@ -18,6 +18,8 @@ | |||
| 18 | 18 | ||
| 19 | #include "snac.h" | 19 | #include "snac.h" |
| 20 | 20 | ||
| 21 | #include <sys/time.h> | ||
| 22 | |||
| 21 | static xs_str *random_str(void) | 23 | static xs_str *random_str(void) |
| 22 | /* just what is says in the tin */ | 24 | /* just what is says in the tin */ |
| 23 | { | 25 | { |
| @@ -129,6 +131,17 @@ xs_dict *token_get(const char *id) | |||
| 129 | if ((f = fopen(fn, "r")) != NULL) { | 131 | if ((f = fopen(fn, "r")) != NULL) { |
| 130 | token = xs_json_load(f); | 132 | token = xs_json_load(f); |
| 131 | fclose(f); | 133 | fclose(f); |
| 134 | |||
| 135 | /* 'touch' the file */ | ||
| 136 | utimes(fn, NULL); | ||
| 137 | |||
| 138 | /* also 'touch' the app */ | ||
| 139 | const char *app_id = xs_dict_get(token, "client_id"); | ||
| 140 | |||
| 141 | if (app_id) { | ||
| 142 | xs *afn = xs_fmt("%s/app/%s.json", srv_basedir, app_id); | ||
| 143 | utimes(afn, NULL); | ||
| 144 | } | ||
| 132 | } | 145 | } |
| 133 | 146 | ||
| 134 | return token; | 147 | return token; |