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