AmendHub

Download

jcs

/

subtext

/

board.h

 

(View History)

jcs   board: Move reindexing to periodic_jobs thread Latest amendment: 597 on 2024-05-20

1 /*
2 * Copyright (c) 2022 joshua stein <jcs@jcs.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef __BOARD_H__
18 #define __BOARD_H__
19
20 #include <stddef.h>
21 #include "fidopkt.h"
22 #include "session.h"
23 #include "settings.h"
24
25 struct board {
26 unsigned long id;
27 char name[32];
28 char description[100];
29 bool restricted_posting;
30 bool restricted_viewing;
31 unsigned short retention_days;
32 unsigned long last_post_at;
33 unsigned long post_count;
34 char ftn_area[32];
35
36 struct bile *bile;
37 bool need_reindex;
38 };
39
40 extern const struct struct_field board_fields[];
41 extern const size_t nboard_fields;
42 extern const struct bile_object_field board_object_fields[];
43 extern const size_t nboard_object_fields;
44
45 struct board_post {
46 unsigned long id;
47 unsigned long thread_id;
48 time_t time;
49 unsigned long sender_user_id;
50 size_t body_size;
51 char *body;
52 unsigned long parent_post_id;
53 char via[10];
54 };
55 extern const struct bile_object_field board_post_object_fields[];
56 extern const size_t nboard_post_object_fields;
57
58 struct board_ftn_post {
59 unsigned long id;
60 struct fidopkt_msgid msgid;
61 time_t time;
62 char from[32];
63 char subject[80];
64 char msgid_orig[64];
65 char origin[64];
66 char reply[32];
67 char to[32];
68 size_t body_size;
69 char *body;
70 };
71 extern const struct bile_object_field board_ftn_post_object_fields[];
72 extern const size_t nboard_ftn_post_object_fields;
73
74 struct board_thread {
75 unsigned long thread_id;
76 time_t last_post_at;
77 size_t subject_size;
78 char *subject;
79 unsigned long nposts;
80 unsigned long *post_ids;
81 unsigned long *parent_post_ids;
82 };
83 extern const struct bile_object_field board_thread_object_fields[];
84 extern const size_t nboard_thread_object_fields;
85
86 struct board_id_time_map {
87 unsigned long id;
88 time_t time;
89 };
90
91 void board_list_boards(struct session *s);
92 void board_list_ftn_areas(struct session *s);
93 void board_show(struct session *s, short id, char *prompt_prefix);
94 void board_delete_post(struct board *board, struct board_post *post,
95 struct board_thread *thread);
96 void board_delete_ftn_post(struct board *board,
97 struct board_ftn_post *post);
98 size_t board_index_sorted_post_ids(struct board *board,
99 struct board_id_time_map **sorted_id_map);
100 short board_toss_ftn_message(struct board *board,
101 struct fidopkt_message *fidomsg, bool local);
102 void board_prune_old_posts(struct board *board);
103
104 #endif