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