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