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