]> Untitled Git - lemmy.git/blob - ui/src/interfaces.ts
Showing community count on main sidebar
[lemmy.git] / ui / src / interfaces.ts
1 export enum UserOperation {
2   Login, Register, CreateCommunity, CreatePost, ListCommunities, ListCategories, GetPost, GetCommunity, CreateComment, EditComment, SaveComment, CreateCommentLike, GetPosts, CreatePostLike, EditPost, SavePost, EditCommunity, FollowCommunity, GetFollowedCommunities, GetUserDetails, GetReplies, GetModlog, BanFromCommunity, AddModToCommunity, CreateSite, EditSite, GetSite, AddAdmin, BanUser, Search, MarkAllAsRead, SaveUserSettings, TransferCommunity, TransferSite
3 }
4
5 export enum CommentSortType {
6   Hot, Top, New
7 }
8
9 export enum ListingType {
10   All, Subscribed, Community
11 }
12
13 export enum SortType {
14   Hot, New, TopDay, TopWeek, TopMonth, TopYear, TopAll
15 }
16
17 export enum SearchType {
18   All, Comments, Posts, Communities, Users, Url
19 }
20
21 export interface User {
22   id: number;
23   iss: string;
24   username: string;
25   show_nsfw: boolean;
26 }
27
28 export interface UserView {
29   id: number;
30   name: string;
31   fedi_name: string;
32   published: string;
33   number_of_posts: number;
34   post_score: number;
35   number_of_comments: number;
36   comment_score: number;
37 }
38
39 export interface CommunityUser {
40   id: number;
41   user_id: number;
42   user_name: string;
43   community_id: number;
44   community_name: string;
45   published: string;
46 }
47
48 export interface Community {
49   id: number;
50   name: string;
51   title: string;
52   description?: string;
53   category_id: number;
54   creator_id: number;
55   removed: boolean;
56   deleted: boolean;
57   nsfw: boolean;
58   published: string;
59   updated?: string;
60   creator_name: string;
61   category_name: string;
62   number_of_subscribers: number;
63   number_of_posts: number;
64   number_of_comments: number;
65   user_id?: number;
66   subscribed?: boolean;
67 }
68
69 export interface Post {
70   id: number;
71   name: string;
72   url?: string;
73   body?: string;
74   creator_id: number;
75   community_id: number;
76   removed: boolean;
77   deleted: boolean;
78   locked: boolean;
79   nsfw: boolean;
80   published: string;
81   updated?: string;
82   creator_name: string;
83   community_name: string;
84   community_removed: boolean;
85   community_deleted: boolean;
86   community_nsfw: boolean;
87   number_of_comments: number;
88   score: number;
89   upvotes: number;
90   downvotes: number;
91   hot_rank: number;
92   user_id?: number;
93   my_vote?: number;
94   subscribed?: boolean;
95   read?: boolean;
96   saved?: boolean;
97 }
98
99 export interface Comment {
100   id: number;
101   creator_id: number;
102   post_id: number,
103   parent_id?: number;
104   content: string;
105   removed: boolean;
106   deleted: boolean;
107   read: boolean;
108   published: string;
109   updated?: string;
110   community_id: number,
111   banned: boolean;
112   banned_from_community: boolean;
113   creator_name: string;
114   score: number;
115   upvotes: number;
116   downvotes: number;
117   user_id?: number;
118   my_vote?: number;
119   saved?: boolean;
120 }
121
122 export interface Category {
123   id: number;
124   name: string;
125 }
126
127 export interface Site {
128   id: number;
129   name: string;
130   description?: string;
131   creator_id: number;
132   published: string;
133   updated?: string;
134   creator_name: string;
135   number_of_users: number;
136   number_of_posts: number;
137   number_of_comments: number;
138   number_of_communities: number;
139 }
140
141 export interface FollowCommunityForm {
142   community_id: number;
143   follow: boolean;
144   auth?: string;
145 }
146
147 export interface GetFollowedCommunitiesResponse {
148   op: string;
149   communities: Array<CommunityUser>;
150 }
151
152 export interface GetUserDetailsForm {
153   user_id?: number;
154   username?: string;
155   sort: string;
156   page?: number;
157   limit?: number;
158   community_id?: number;
159   saved_only: boolean;
160 }
161
162 export interface UserDetailsResponse {
163   op: string;
164   user: UserView;
165   follows: Array<CommunityUser>;
166   moderates: Array<CommunityUser>;
167   comments: Array<Comment>;
168   posts: Array<Post>;
169 }
170
171 export interface GetRepliesForm {
172   sort: string; // TODO figure this one out
173   page?: number;
174   limit?: number;
175   unread_only: boolean;
176   auth?: string;
177 }
178
179 export interface GetRepliesResponse {
180   op: string;
181   replies: Array<Comment>;
182 }
183
184 export interface BanFromCommunityForm {
185   community_id: number;
186   user_id: number;
187   ban: boolean;
188   reason?: string,
189   expires?: number,
190   auth?: string;
191 }
192
193 export interface BanFromCommunityResponse {
194   op: string;
195   user: UserView,
196   banned: boolean,
197 }
198
199 export interface AddModToCommunityForm {
200   community_id: number;
201   user_id: number;
202   added: boolean;
203   auth?: string;
204 }
205
206 export interface TransferCommunityForm {
207   community_id: number;
208   user_id: number;
209   auth?: string;
210 }
211
212 export interface TransferSiteForm {
213   user_id: number;
214   auth?: string;
215 }
216
217 export interface AddModToCommunityResponse {
218   op: string;
219   moderators: Array<CommunityUser>;
220 }
221
222 export interface GetModlogForm {
223   mod_user_id?: number;
224   community_id?: number;
225   page?: number;
226   limit?: number;
227 }
228
229 export interface GetModlogResponse {
230   op: string;
231   removed_posts: Array<ModRemovePost>,
232   locked_posts: Array<ModLockPost>,
233   removed_comments: Array<ModRemoveComment>,
234   removed_communities: Array<ModRemoveCommunity>,
235   banned_from_community: Array<ModBanFromCommunity>,
236   banned: Array<ModBan>,
237   added_to_community: Array<ModAddCommunity>,
238   added: Array<ModAdd>,
239 }
240
241 export interface ModRemovePost {
242   id: number;
243   mod_user_id: number;
244   post_id: number;
245   reason?: string;
246   removed?: boolean;
247   when_: string
248   mod_user_name: string;
249   post_name: string;
250   community_id: number;
251   community_name: string;
252 }
253
254 export interface ModLockPost {
255   id: number,
256   mod_user_id: number,
257   post_id: number,
258   locked?: boolean,
259   when_: string,
260   mod_user_name: string,
261   post_name: string,
262   community_id: number,
263   community_name: string,
264 }
265
266 export interface ModRemoveComment {
267   id: number,
268   mod_user_id: number,
269   comment_id: number,
270   reason?: string,
271   removed?: boolean,
272   when_: string,
273   mod_user_name: string,
274   comment_user_id: number,
275   comment_user_name: string,
276   comment_content: string,
277   post_id: number,
278   post_name: string,
279   community_id: number,
280   community_name: string,
281 }
282
283 export interface ModRemoveCommunity {
284   id: number,
285   mod_user_id: number,
286   community_id: number,
287   reason?: string,
288   removed?: boolean,
289   expires?: number,
290   when_: string,
291   mod_user_name: string,
292   community_name: string,
293 }
294
295 export interface ModBanFromCommunity {
296   id: number,
297   mod_user_id: number,
298   other_user_id: number,
299   community_id: number,
300   reason?: string,
301   banned?: boolean,
302   expires?: number,
303   when_: string,
304   mod_user_name: string,
305   other_user_name: string,
306   community_name: string,
307 }
308
309 export interface ModBan {
310   id: number,
311   mod_user_id: number,
312   other_user_id: number,
313   reason?: string,
314   banned?: boolean,
315   expires?: number,
316   when_: string,
317   mod_user_name: string,
318   other_user_name: string,
319 }
320
321 export interface ModAddCommunity {
322   id: number,
323   mod_user_id: number,
324   other_user_id: number,
325   community_id: number,
326   removed?: boolean,
327   when_: string,
328   mod_user_name: string,
329   other_user_name: string,
330   community_name: string,
331 }
332
333 export interface ModAdd {
334   id: number,
335   mod_user_id: number,
336   other_user_id: number,
337   removed?: boolean,
338   when_: string,
339   mod_user_name: string,
340   other_user_name: string,
341 }
342
343 export interface LoginForm {
344   username_or_email: string;
345   password: string;
346 }
347
348 export interface RegisterForm {
349   username: string;
350   email?: string;
351   password: string;
352   password_verify: string;
353   admin: boolean;
354   show_nsfw: boolean;
355 }
356
357 export interface LoginResponse {
358   op: string;
359   jwt: string;
360 }
361
362 export interface UserSettingsForm {
363   show_nsfw: boolean;
364   auth: string;
365 }
366
367 export interface CommunityForm {
368   name: string;
369   title: string;
370   description?: string,
371   category_id: number,
372   edit_id?: number;
373   removed?: boolean;
374   deleted?: boolean;
375   nsfw: boolean;
376   reason?: string;
377   expires?: number;
378   auth?: string;
379 }
380
381 export interface GetCommunityResponse {
382   op: string;
383   community: Community;
384   moderators: Array<CommunityUser>;
385   admins: Array<UserView>;
386 }
387
388
389 export interface CommunityResponse {
390   op: string;
391   community: Community;
392 }
393
394 export interface ListCommunitiesForm {
395   sort: string;
396   page?: number;
397   limit?: number;
398   auth?: string;
399 }
400
401 export interface ListCommunitiesResponse {
402   op: string;
403   communities: Array<Community>;
404 }
405
406 export interface ListCategoriesResponse {
407   op: string;
408   categories: Array<Category>;
409 }
410
411 export interface PostForm {
412   name: string;
413   url?: string;
414   body?: string;
415   community_id: number;
416   updated?: number;
417   edit_id?: number;
418   creator_id: number;
419   removed?: boolean;
420   deleted?: boolean;
421   nsfw: boolean;
422   locked?: boolean;
423   reason?: string;
424   auth: string;
425 }
426
427 export interface PostFormParams {
428   name: string;
429   url?: string;
430   body?: string;
431   community?: string;
432 }
433
434 export interface GetPostResponse {
435   op: string;
436   post: Post;
437   comments: Array<Comment>;
438   community: Community;
439   moderators: Array<CommunityUser>;
440   admins: Array<UserView>;
441 }
442
443 export interface SavePostForm {
444   post_id: number;
445   save: boolean;
446   auth?: string;
447 }
448
449 export interface PostResponse {
450   op: string;
451   post: Post;
452 }
453
454 export interface CommentForm {
455   content: string;
456   post_id: number;
457   parent_id?: number;
458   edit_id?: number;
459   creator_id: number;
460   removed?: boolean;
461   deleted?: boolean;
462   reason?: string;
463   read?: boolean;
464   auth: string;
465 }
466
467 export interface SaveCommentForm {
468   comment_id: number;
469   save: boolean;
470   auth?: string;
471 }
472
473 export interface CommentResponse {
474   op: string;
475   comment: Comment;
476 }
477
478 export interface CommentLikeForm {
479   comment_id: number;
480   post_id: number;
481   score: number;
482   auth?: string;
483 }
484
485 export interface CommentNode {
486   comment: Comment;
487   children?: Array<CommentNode>;
488 }
489
490 export interface GetPostsForm {
491   type_: string;
492   sort: string;
493   page?: number;
494   limit?: number;
495   community_id?: number;
496   auth?: string;
497 }
498
499 export interface GetPostsResponse {
500   op: string;
501   posts: Array<Post>;
502 }
503
504 export interface CreatePostLikeForm {
505   post_id: number;
506   score: number;
507   auth?: string;
508 }
509
510 export interface CreatePostLikeResponse {
511   op: string;
512   post: Post;
513 }
514
515 export interface SiteForm {
516   name: string;
517   description?: string,
518   removed?: boolean;
519   reason?: string;
520   expires?: number;
521   auth?: string;
522 }
523
524 export interface GetSiteResponse {
525   op: string;
526   site: Site;
527   admins: Array<UserView>;
528   banned: Array<UserView>;
529 }
530
531
532 export interface SiteResponse {
533   op: string;
534   site: Site;
535 }
536
537 export interface BanUserForm {
538   user_id: number;
539   ban: boolean;
540   reason?: string,
541   expires?: number,
542   auth?: string;
543 }
544
545 export interface BanUserResponse {
546   op: string;
547   user: UserView,
548   banned: boolean,
549 }
550
551 export interface AddAdminForm {
552   user_id: number;
553   added: boolean;
554   auth?: string;
555 }
556
557 export interface AddAdminResponse {
558   op: string;
559   admins: Array<UserView>;
560 }
561
562 export interface SearchForm {
563   q: string;
564   type_: string;
565   community_id?: number;
566   sort: string;
567   page?: number;
568   limit?: number;
569 }
570
571 export interface SearchResponse {
572   op: string;
573   type_: string;
574   posts?: Array<Post>;
575   comments?: Array<Comment>;
576   communities: Array<Community>;  
577   users: Array<UserView>;
578 }