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