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