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