diff options
| author | 2023-03-02 09:15:40 +0100 | |
|---|---|---|
| committer | 2023-03-02 09:15:40 +0100 | |
| commit | 29b12498dd511b00586446b98f11ccb1d44088eb (patch) | |
| tree | 3b7178a7770a4d99712b6b69f9848d7b71d51085 /data.c | |
| parent | Renamed inboxes/ to inbox/. (diff) | |
| download | snac2-29b12498dd511b00586446b98f11ccb1d44088eb.tar.gz snac2-29b12498dd511b00586446b98f11ccb1d44088eb.tar.xz snac2-29b12498dd511b00586446b98f11ccb1d44088eb.zip | |
Simplified is_msg_public().
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 31 |
1 files changed, 26 insertions, 5 deletions
| @@ -1375,7 +1375,7 @@ void inbox_add(const char *inbox) | |||
| 1375 | xs *fn = xs_fmt("%s/inbox/%s", srv_basedir, md5); | 1375 | xs *fn = xs_fmt("%s/inbox/%s", srv_basedir, md5); |
| 1376 | FILE *f; | 1376 | FILE *f; |
| 1377 | 1377 | ||
| 1378 | if ((f = fopen(fn, "w")) != NULL) { | 1378 | if (strlen(inbox) < 256 && (f = fopen(fn, "w")) != NULL) { |
| 1379 | pthread_mutex_lock(&data_mutex); | 1379 | pthread_mutex_lock(&data_mutex); |
| 1380 | 1380 | ||
| 1381 | fprintf(f, "%s\n", inbox); | 1381 | fprintf(f, "%s\n", inbox); |
| @@ -1397,15 +1397,36 @@ void inbox_add_by_actor(const xs_dict *actor) | |||
| 1397 | } | 1397 | } |
| 1398 | 1398 | ||
| 1399 | 1399 | ||
| 1400 | #if 0 | ||
| 1401 | xs_list *inbox_list(void) | 1400 | xs_list *inbox_list(void) |
| 1402 | /* returns the collected inboxes as a list */ | 1401 | /* returns the collected inboxes as a list */ |
| 1403 | { | 1402 | { |
| 1404 | xs_list *l = xs_list_new(); | 1403 | xs_list *ibl = xs_list_new(); |
| 1404 | xs *spec = xs_fmt("%s/inbox/" "*", srv_basedir); | ||
| 1405 | xs *files = xs_glob(spec, 0, 0); | ||
| 1406 | xs_list *p = files; | ||
| 1407 | xs_val *v; | ||
| 1408 | |||
| 1409 | while (xs_list_iter(&p, &v)) { | ||
| 1410 | FILE *f; | ||
| 1411 | |||
| 1412 | if ((f = fopen(v, "r")) != NULL) { | ||
| 1413 | char line[256]; | ||
| 1414 | |||
| 1415 | if (fgets(line, sizeof(line), f)) { | ||
| 1416 | fclose(f); | ||
| 1417 | |||
| 1418 | int i = strlen(line); | ||
| 1419 | |||
| 1420 | if (i) { | ||
| 1421 | line[i - 1] = '\0'; | ||
| 1422 | ibl = xs_list_append(ibl, line); | ||
| 1423 | } | ||
| 1424 | } | ||
| 1425 | } | ||
| 1426 | } | ||
| 1405 | 1427 | ||
| 1406 | return l; | 1428 | return ibl; |
| 1407 | } | 1429 | } |
| 1408 | #endif | ||
| 1409 | 1430 | ||
| 1410 | 1431 | ||
| 1411 | /** the queue **/ | 1432 | /** the queue **/ |