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