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