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