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