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