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