]> Untitled Git - lemmy.git/blob - ui/src/interfaces.ts
Merge pull request 'Disable rate limiting for pictrs' (#79) from pictrs-disable-rate...
[lemmy.git] / ui / src / interfaces.ts
1 export enum UserOperation {
2   Login,
3   Register,
4   GetCaptcha,
5   CreateCommunity,
6   CreatePost,
7   ListCommunities,
8   ListCategories,
9   GetPost,
10   GetCommunity,
11   CreateComment,
12   EditComment,
13   DeleteComment,
14   RemoveComment,
15   MarkCommentAsRead,
16   SaveComment,
17   CreateCommentLike,
18   GetPosts,
19   CreatePostLike,
20   EditPost,
21   DeletePost,
22   RemovePost,
23   LockPost,
24   StickyPost,
25   SavePost,
26   EditCommunity,
27   DeleteCommunity,
28   RemoveCommunity,
29   FollowCommunity,
30   GetFollowedCommunities,
31   GetUserDetails,
32   GetReplies,
33   GetUserMentions,
34   MarkUserMentionAsRead,
35   GetModlog,
36   BanFromCommunity,
37   AddModToCommunity,
38   CreateSite,
39   EditSite,
40   GetSite,
41   AddAdmin,
42   BanUser,
43   Search,
44   MarkAllAsRead,
45   SaveUserSettings,
46   TransferCommunity,
47   TransferSite,
48   DeleteAccount,
49   PasswordReset,
50   PasswordChange,
51   CreatePrivateMessage,
52   EditPrivateMessage,
53   DeletePrivateMessage,
54   MarkPrivateMessageAsRead,
55   GetPrivateMessages,
56   UserJoin,
57   GetComments,
58   GetSiteConfig,
59   SaveSiteConfig,
60 }
61
62 export enum CommentSortType {
63   Hot,
64   Top,
65   New,
66   Old,
67 }
68
69 export enum CommentViewType {
70   Tree,
71   Chat,
72 }
73
74 export enum ListingType {
75   All,
76   Subscribed,
77   Community,
78 }
79
80 export enum DataType {
81   Post,
82   Comment,
83 }
84
85 export enum SortType {
86   Active,
87   Hot,
88   New,
89   TopDay,
90   TopWeek,
91   TopMonth,
92   TopYear,
93   TopAll,
94 }
95
96 export enum SearchType {
97   All,
98   Comments,
99   Posts,
100   Communities,
101   Users,
102   Url,
103 }
104
105 export interface Claims {
106   id: number;
107   iss: string;
108 }
109
110 export interface User {
111   id: number;
112   name: string;
113   preferred_username?: string;
114   email?: string;
115   avatar?: string;
116   banner?: string;
117   admin: boolean;
118   banned: boolean;
119   published: string;
120   updated?: string;
121   show_nsfw: boolean;
122   theme: string;
123   default_sort_type: SortType;
124   default_listing_type: ListingType;
125   lang: string;
126   show_avatars: boolean;
127   send_notifications_to_email: boolean;
128   matrix_user_id?: string;
129   actor_id: string;
130   bio?: string;
131   local: boolean;
132   last_refreshed_at: string;
133 }
134
135 export interface UserView {
136   id: number;
137   actor_id: string;
138   name: string;
139   preferred_username?: string;
140   avatar?: string;
141   banner?: string;
142   matrix_user_id?: string;
143   bio?: string;
144   local: boolean;
145   published: string;
146   number_of_posts: number;
147   post_score: number;
148   number_of_comments: number;
149   comment_score: number;
150   banned: boolean;
151 }
152
153 export interface CommunityUser {
154   id: number;
155   user_id: number;
156   user_actor_id: string;
157   user_local: boolean;
158   user_name: string;
159   user_preferred_username?: string;
160   avatar?: string;
161   community_id: number;
162   community_actor_id: string;
163   community_local: boolean;
164   community_name: string;
165   community_icon?: string;
166   published: string;
167 }
168
169 export interface Community {
170   id: number;
171   actor_id: string;
172   local: boolean;
173   name: string;
174   title: string;
175   icon?: string;
176   banner?: string;
177   description?: string;
178   category_id: number;
179   creator_id: number;
180   removed: boolean;
181   deleted: boolean;
182   nsfw: boolean;
183   published: string;
184   updated?: string;
185   creator_actor_id: string;
186   creator_local: boolean;
187   last_refreshed_at: string;
188   creator_name: string;
189   creator_preferred_username?: string;
190   creator_avatar?: string;
191   category_name: string;
192   number_of_subscribers: number;
193   number_of_posts: number;
194   number_of_comments: number;
195   user_id?: number;
196   subscribed?: boolean;
197 }
198
199 export interface Post {
200   id: number;
201   name: string;
202   url?: string;
203   body?: string;
204   creator_id: number;
205   community_id: number;
206   removed: boolean;
207   deleted: boolean;
208   locked: boolean;
209   stickied: boolean;
210   embed_title?: string;
211   embed_description?: string;
212   embed_html?: string;
213   thumbnail_url?: string;
214   ap_id: string;
215   local: boolean;
216   nsfw: boolean;
217   banned: boolean;
218   banned_from_community: boolean;
219   published: string;
220   updated?: string;
221   creator_actor_id: string;
222   creator_local: boolean;
223   creator_name: string;
224   creator_preferred_username?: string;
225   creator_published: string;
226   creator_avatar?: string;
227   community_actor_id: string;
228   community_local: boolean;
229   community_name: string;
230   community_icon?: string;
231   community_removed: boolean;
232   community_deleted: boolean;
233   community_nsfw: boolean;
234   number_of_comments: number;
235   score: number;
236   upvotes: number;
237   downvotes: number;
238   hot_rank: number;
239   hot_rank_active: number;
240   newest_activity_time: string;
241   user_id?: number;
242   my_vote?: number;
243   subscribed?: boolean;
244   read?: boolean;
245   saved?: boolean;
246   duplicates?: Array<Post>;
247 }
248
249 export interface Comment {
250   id: number;
251   ap_id: string;
252   local: boolean;
253   creator_id: number;
254   post_id: number;
255   post_name: string;
256   parent_id?: number;
257   content: string;
258   removed: boolean;
259   deleted: boolean;
260   read: boolean;
261   published: string;
262   updated?: string;
263   community_id: number;
264   community_actor_id: string;
265   community_local: boolean;
266   community_name: string;
267   community_icon?: string;
268   banned: boolean;
269   banned_from_community: boolean;
270   creator_actor_id: string;
271   creator_local: boolean;
272   creator_name: string;
273   creator_preferred_username?: string;
274   creator_avatar?: string;
275   creator_published: string;
276   score: number;
277   upvotes: number;
278   downvotes: number;
279   hot_rank: number;
280   hot_rank_active: number;
281   user_id?: number;
282   my_vote?: number;
283   subscribed?: number;
284   saved?: boolean;
285   user_mention_id?: number; // For mention type
286   recipient_id?: number;
287   recipient_actor_id?: string;
288   recipient_local?: boolean;
289   depth?: number;
290 }
291
292 export interface Category {
293   id: number;
294   name: string;
295 }
296
297 export interface Site {
298   id: number;
299   name: string;
300   description?: string;
301   creator_id: number;
302   published: string;
303   updated?: string;
304   creator_name: string;
305   creator_preferred_username?: string;
306   number_of_users: number;
307   number_of_posts: number;
308   number_of_comments: number;
309   number_of_communities: number;
310   enable_downvotes: boolean;
311   open_registration: boolean;
312   enable_nsfw: boolean;
313   icon?: string;
314   banner?: string;
315 }
316
317 export interface PrivateMessage {
318   id: number;
319   creator_id: number;
320   recipient_id: number;
321   content: string;
322   deleted: boolean;
323   read: boolean;
324   published: string;
325   updated?: string;
326   ap_id: string;
327   local: boolean;
328   creator_name: string;
329   creator_preferred_username?: string;
330   creator_avatar?: string;
331   creator_actor_id: string;
332   creator_local: boolean;
333   recipient_name: string;
334   recipient_preferred_username?: string;
335   recipient_avatar?: string;
336   recipient_actor_id: string;
337   recipient_local: boolean;
338 }
339
340 export enum BanType {
341   Community,
342   Site,
343 }
344
345 export interface FollowCommunityForm {
346   community_id: number;
347   follow: boolean;
348   auth?: string;
349 }
350
351 export interface GetFollowedCommunitiesForm {
352   auth: string;
353 }
354
355 export interface GetFollowedCommunitiesResponse {
356   communities: Array<CommunityUser>;
357 }
358
359 export interface GetUserDetailsForm {
360   user_id?: number;
361   username?: string;
362   sort: string;
363   page?: number;
364   limit?: number;
365   community_id?: number;
366   saved_only: boolean;
367 }
368
369 export interface UserDetailsResponse {
370   user: UserView;
371   follows: Array<CommunityUser>;
372   moderates: Array<CommunityUser>;
373   comments: Array<Comment>;
374   posts: Array<Post>;
375   admins: Array<UserView>;
376 }
377
378 export interface GetRepliesForm {
379   sort: string;
380   page?: number;
381   limit?: number;
382   unread_only: boolean;
383   auth?: string;
384 }
385
386 export interface GetRepliesResponse {
387   replies: Array<Comment>;
388 }
389
390 export interface GetUserMentionsForm {
391   sort: string;
392   page?: number;
393   limit?: number;
394   unread_only: boolean;
395   auth?: string;
396 }
397
398 export interface GetUserMentionsResponse {
399   mentions: Array<Comment>;
400 }
401
402 export interface MarkUserMentionAsReadForm {
403   user_mention_id: number;
404   read: boolean;
405   auth?: string;
406 }
407
408 export interface UserMentionResponse {
409   mention: Comment;
410 }
411
412 export interface BanFromCommunityForm {
413   community_id: number;
414   user_id: number;
415   ban: boolean;
416   reason?: string;
417   expires?: number;
418   auth?: string;
419 }
420
421 export interface BanFromCommunityResponse {
422   user: UserView;
423   banned: boolean;
424 }
425
426 export interface AddModToCommunityForm {
427   community_id: number;
428   user_id: number;
429   added: boolean;
430   auth?: string;
431 }
432
433 export interface TransferCommunityForm {
434   community_id: number;
435   user_id: number;
436   auth?: string;
437 }
438
439 export interface TransferSiteForm {
440   user_id: number;
441   auth?: string;
442 }
443
444 export interface AddModToCommunityResponse {
445   moderators: Array<CommunityUser>;
446 }
447
448 export interface GetModlogForm {
449   mod_user_id?: number;
450   community_id?: number;
451   page?: number;
452   limit?: number;
453 }
454
455 export interface GetModlogResponse {
456   removed_posts: Array<ModRemovePost>;
457   locked_posts: Array<ModLockPost>;
458   stickied_posts: Array<ModStickyPost>;
459   removed_comments: Array<ModRemoveComment>;
460   removed_communities: Array<ModRemoveCommunity>;
461   banned_from_community: Array<ModBanFromCommunity>;
462   banned: Array<ModBan>;
463   added_to_community: Array<ModAddCommunity>;
464   added: Array<ModAdd>;
465 }
466
467 export interface ModRemovePost {
468   id: number;
469   mod_user_id: number;
470   post_id: number;
471   reason?: string;
472   removed?: boolean;
473   when_: string;
474   mod_user_name: string;
475   post_name: string;
476   community_id: number;
477   community_name: string;
478 }
479
480 export interface ModLockPost {
481   id: number;
482   mod_user_id: number;
483   post_id: number;
484   locked?: boolean;
485   when_: string;
486   mod_user_name: string;
487   post_name: string;
488   community_id: number;
489   community_name: string;
490 }
491
492 export interface ModStickyPost {
493   id: number;
494   mod_user_id: number;
495   post_id: number;
496   stickied?: boolean;
497   when_: string;
498   mod_user_name: string;
499   post_name: string;
500   community_id: number;
501   community_name: string;
502 }
503
504 export interface ModRemoveComment {
505   id: number;
506   mod_user_id: number;
507   comment_id: number;
508   reason?: string;
509   removed?: boolean;
510   when_: string;
511   mod_user_name: string;
512   comment_user_id: number;
513   comment_user_name: string;
514   comment_content: string;
515   post_id: number;
516   post_name: string;
517   community_id: number;
518   community_name: string;
519 }
520
521 export interface ModRemoveCommunity {
522   id: number;
523   mod_user_id: number;
524   community_id: number;
525   reason?: string;
526   removed?: boolean;
527   expires?: number;
528   when_: string;
529   mod_user_name: string;
530   community_name: string;
531 }
532
533 export interface ModBanFromCommunity {
534   id: number;
535   mod_user_id: number;
536   other_user_id: number;
537   community_id: number;
538   reason?: string;
539   banned?: boolean;
540   expires?: number;
541   when_: string;
542   mod_user_name: string;
543   other_user_name: string;
544   community_name: string;
545 }
546
547 export interface ModBan {
548   id: number;
549   mod_user_id: number;
550   other_user_id: number;
551   reason?: string;
552   banned?: boolean;
553   expires?: number;
554   when_: string;
555   mod_user_name: string;
556   other_user_name: string;
557 }
558
559 export interface ModAddCommunity {
560   id: number;
561   mod_user_id: number;
562   other_user_id: number;
563   community_id: number;
564   removed?: boolean;
565   when_: string;
566   mod_user_name: string;
567   other_user_name: string;
568   community_name: string;
569 }
570
571 export interface ModAdd {
572   id: number;
573   mod_user_id: number;
574   other_user_id: number;
575   removed?: boolean;
576   when_: string;
577   mod_user_name: string;
578   other_user_name: string;
579 }
580
581 export interface LoginForm {
582   username_or_email: string;
583   password: string;
584 }
585
586 export interface RegisterForm {
587   username: string;
588   email?: string;
589   password: string;
590   password_verify: string;
591   admin: boolean;
592   show_nsfw: boolean;
593   captcha_uuid?: string;
594   captcha_answer?: string;
595 }
596
597 export interface GetCaptchaResponse {
598   ok?: {
599     png: string;
600     wav?: string;
601     uuid: string;
602   };
603 }
604
605 export interface LoginResponse {
606   jwt: string;
607 }
608
609 export interface UserSettingsForm {
610   show_nsfw: boolean;
611   theme: string;
612   default_sort_type: SortType;
613   default_listing_type: ListingType;
614   lang: string;
615   avatar?: string;
616   banner?: string;
617   preferred_username?: string;
618   email?: string;
619   bio?: string;
620   matrix_user_id?: string;
621   new_password?: string;
622   new_password_verify?: string;
623   old_password?: string;
624   show_avatars: boolean;
625   send_notifications_to_email: boolean;
626   auth: string;
627 }
628
629 export interface CommunityForm {
630   name: string;
631   edit_id?: number;
632   title: string;
633   description?: string;
634   icon?: string;
635   banner?: string;
636   category_id: number;
637   nsfw: boolean;
638   auth?: string;
639 }
640
641 export interface DeleteCommunityForm {
642   edit_id: number;
643   deleted: boolean;
644   auth?: string;
645 }
646
647 export interface RemoveCommunityForm {
648   edit_id: number;
649   removed: boolean;
650   reason?: string;
651   expires?: number;
652   auth?: string;
653 }
654
655 export interface GetCommunityForm {
656   id?: number;
657   name?: string;
658   auth?: string;
659 }
660
661 export interface GetCommunityResponse {
662   community: Community;
663   moderators: Array<CommunityUser>;
664   online: number;
665 }
666
667 export interface CommunityResponse {
668   community: Community;
669 }
670
671 export interface ListCommunitiesForm {
672   sort: string;
673   page?: number;
674   limit?: number;
675   auth?: string;
676 }
677
678 export interface ListCommunitiesResponse {
679   communities: Array<Community>;
680 }
681
682 export interface ListCategoriesResponse {
683   categories: Array<Category>;
684 }
685
686 export interface PostForm {
687   name: string;
688   url?: string;
689   body?: string;
690   community_id?: number;
691   edit_id?: number;
692   nsfw: boolean;
693   auth: string;
694 }
695
696 export interface DeletePostForm {
697   edit_id: number;
698   deleted: boolean;
699   auth: string;
700 }
701
702 export interface RemovePostForm {
703   edit_id: number;
704   removed: boolean;
705   reason?: string;
706   auth: string;
707 }
708
709 export interface LockPostForm {
710   edit_id: number;
711   locked: boolean;
712   auth: string;
713 }
714
715 export interface StickyPostForm {
716   edit_id: number;
717   stickied: boolean;
718   auth: string;
719 }
720
721 export interface PostFormParams {
722   name: string;
723   url?: string;
724   body?: string;
725   community?: string;
726 }
727
728 export interface GetPostForm {
729   id: number;
730   auth?: string;
731 }
732
733 export interface GetPostResponse {
734   post: Post;
735   comments: Array<Comment>;
736   community: Community;
737   moderators: Array<CommunityUser>;
738   online: number;
739 }
740
741 export interface SavePostForm {
742   post_id: number;
743   save: boolean;
744   auth?: string;
745 }
746
747 export interface PostResponse {
748   post: Post;
749 }
750
751 export interface CommentForm {
752   content: string;
753   post_id?: number;
754   parent_id?: number;
755   edit_id?: number;
756   creator_id?: number;
757   form_id?: string;
758   auth: string;
759 }
760
761 export interface DeleteCommentForm {
762   edit_id: number;
763   deleted: boolean;
764   auth: string;
765 }
766
767 export interface RemoveCommentForm {
768   edit_id: number;
769   removed: boolean;
770   reason?: string;
771   auth: string;
772 }
773
774 export interface MarkCommentAsReadForm {
775   edit_id: number;
776   read: boolean;
777   auth: string;
778 }
779
780 export interface SaveCommentForm {
781   comment_id: number;
782   save: boolean;
783   auth?: string;
784 }
785
786 export interface CommentResponse {
787   comment: Comment;
788   recipient_ids: Array<number>;
789   form_id?: string;
790 }
791
792 export interface CommentLikeForm {
793   comment_id: number;
794   score: number;
795   auth?: string;
796 }
797
798 export interface CommentNode {
799   comment: Comment;
800   children?: Array<CommentNode>;
801 }
802
803 export interface GetPostsForm {
804   type_: string;
805   sort: string;
806   page?: number;
807   limit?: number;
808   community_id?: number;
809   auth?: string;
810 }
811
812 export interface GetPostsResponse {
813   posts: Array<Post>;
814 }
815
816 export interface GetCommentsForm {
817   type_: string;
818   sort: string;
819   page?: number;
820   limit: number;
821   community_id?: number;
822   auth?: string;
823 }
824
825 export interface GetCommentsResponse {
826   comments: Array<Comment>;
827 }
828
829 export interface CreatePostLikeForm {
830   post_id: number;
831   score: number;
832   auth?: string;
833 }
834
835 export interface SiteForm {
836   name: string;
837   description?: string;
838   icon?: string;
839   banner?: string;
840   enable_downvotes: boolean;
841   open_registration: boolean;
842   enable_nsfw: boolean;
843   auth?: string;
844 }
845
846 export interface GetSiteConfig {
847   auth?: string;
848 }
849
850 export interface GetSiteForm {
851   auth?: string;
852 }
853
854 export interface GetSiteConfigResponse {
855   config_hjson: string;
856 }
857
858 export interface SiteConfigForm {
859   config_hjson: string;
860   auth?: string;
861 }
862
863 export interface GetSiteResponse {
864   site: Site;
865   admins: Array<UserView>;
866   banned: Array<UserView>;
867   online: number;
868   version: string;
869   my_user?: User;
870 }
871
872 export interface SiteResponse {
873   site: Site;
874 }
875
876 export interface BanUserForm {
877   user_id: number;
878   ban: boolean;
879   reason?: string;
880   expires?: number;
881   auth?: string;
882 }
883
884 export interface BanUserResponse {
885   user: UserView;
886   banned: boolean;
887 }
888
889 export interface AddAdminForm {
890   user_id: number;
891   added: boolean;
892   auth?: string;
893 }
894
895 export interface AddAdminResponse {
896   admins: Array<UserView>;
897 }
898
899 export interface SearchForm {
900   q: string;
901   type_: string;
902   community_id?: number;
903   sort: string;
904   page?: number;
905   limit?: number;
906   auth?: string;
907 }
908
909 export interface SearchResponse {
910   type_: string;
911   posts?: Array<Post>;
912   comments?: Array<Comment>;
913   communities: Array<Community>;
914   users: Array<UserView>;
915 }
916
917 export interface DeleteAccountForm {
918   password: string;
919 }
920
921 export interface PasswordResetForm {
922   email: string;
923 }
924
925 // export interface PasswordResetResponse {
926 // }
927
928 export interface PasswordChangeForm {
929   token: string;
930   password: string;
931   password_verify: string;
932 }
933
934 export interface PrivateMessageForm {
935   content: string;
936   recipient_id: number;
937   auth?: string;
938 }
939
940 export interface PrivateMessageFormParams {
941   recipient_id: number;
942 }
943
944 export interface EditPrivateMessageForm {
945   edit_id: number;
946   content: string;
947   auth?: string;
948 }
949
950 export interface DeletePrivateMessageForm {
951   edit_id: number;
952   deleted: boolean;
953   auth?: string;
954 }
955
956 export interface MarkPrivateMessageAsReadForm {
957   edit_id: number;
958   read: boolean;
959   auth?: string;
960 }
961
962 export interface GetPrivateMessagesForm {
963   unread_only: boolean;
964   page?: number;
965   limit?: number;
966   auth?: string;
967 }
968
969 export interface PrivateMessagesResponse {
970   messages: Array<PrivateMessage>;
971 }
972
973 export interface PrivateMessageResponse {
974   message: PrivateMessage;
975 }
976
977 export interface UserJoinForm {
978   auth: string;
979 }
980
981 export interface UserJoinResponse {
982   user_id: number;
983 }
984
985 export type MessageType =
986   | LoginForm
987   | RegisterForm
988   | CommunityForm
989   | DeleteCommunityForm
990   | RemoveCommunityForm
991   | FollowCommunityForm
992   | ListCommunitiesForm
993   | GetFollowedCommunitiesForm
994   | PostForm
995   | DeletePostForm
996   | RemovePostForm
997   | LockPostForm
998   | StickyPostForm
999   | GetPostForm
1000   | GetPostsForm
1001   | GetCommunityForm
1002   | CommentForm
1003   | DeleteCommentForm
1004   | RemoveCommentForm
1005   | MarkCommentAsReadForm
1006   | CommentLikeForm
1007   | SaveCommentForm
1008   | CreatePostLikeForm
1009   | BanFromCommunityForm
1010   | AddAdminForm
1011   | AddModToCommunityForm
1012   | TransferCommunityForm
1013   | TransferSiteForm
1014   | SaveCommentForm
1015   | BanUserForm
1016   | AddAdminForm
1017   | GetUserDetailsForm
1018   | GetRepliesForm
1019   | GetUserMentionsForm
1020   | MarkUserMentionAsReadForm
1021   | GetModlogForm
1022   | SiteForm
1023   | SearchForm
1024   | UserSettingsForm
1025   | DeleteAccountForm
1026   | PasswordResetForm
1027   | PasswordChangeForm
1028   | PrivateMessageForm
1029   | EditPrivateMessageForm
1030   | DeletePrivateMessageForm
1031   | MarkPrivateMessageAsReadForm
1032   | GetPrivateMessagesForm
1033   | SiteConfigForm;
1034
1035 type ResponseType =
1036   | SiteResponse
1037   | GetFollowedCommunitiesResponse
1038   | ListCommunitiesResponse
1039   | GetPostsResponse
1040   | PostResponse
1041   | GetRepliesResponse
1042   | GetUserMentionsResponse
1043   | ListCategoriesResponse
1044   | CommunityResponse
1045   | CommentResponse
1046   | UserMentionResponse
1047   | LoginResponse
1048   | GetCaptchaResponse
1049   | GetModlogResponse
1050   | SearchResponse
1051   | BanFromCommunityResponse
1052   | AddModToCommunityResponse
1053   | BanUserResponse
1054   | AddAdminResponse
1055   | PrivateMessageResponse
1056   | PrivateMessagesResponse
1057   | GetSiteConfigResponse
1058   | GetSiteResponse;
1059
1060 export interface WebSocketResponse {
1061   op: UserOperation;
1062   data: ResponseType;
1063 }
1064
1065 export interface WebSocketJsonResponse {
1066   op?: string;
1067   data?: ResponseType;
1068   error?: string;
1069   reconnect?: boolean;
1070 }
1071
1072 export enum UserDetailsView {
1073   Overview,
1074   Comments,
1075   Posts,
1076   Saved,
1077 }