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