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