]> Untitled Git - lemmy.git/blob - ui/src/interfaces.ts
Merge branch 'private_messaging' into dev
[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   op: string;
253   communities: Array<CommunityUser>;
254 }
255
256 export interface GetUserDetailsForm {
257   user_id?: number;
258   username?: string;
259   sort: string;
260   page?: number;
261   limit?: number;
262   community_id?: number;
263   saved_only: boolean;
264 }
265
266 export interface UserDetailsResponse {
267   op: string;
268   user: UserView;
269   follows: Array<CommunityUser>;
270   moderates: Array<CommunityUser>;
271   comments: Array<Comment>;
272   posts: Array<Post>;
273   admins: Array<UserView>;
274 }
275
276 export interface GetRepliesForm {
277   sort: string;
278   page?: number;
279   limit?: number;
280   unread_only: boolean;
281   auth?: string;
282 }
283
284 export interface GetRepliesResponse {
285   op: string;
286   replies: Array<Comment>;
287 }
288
289 export interface GetUserMentionsForm {
290   sort: string;
291   page?: number;
292   limit?: number;
293   unread_only: boolean;
294   auth?: string;
295 }
296
297 export interface GetUserMentionsResponse {
298   op: string;
299   mentions: Array<Comment>;
300 }
301
302 export interface EditUserMentionForm {
303   user_mention_id: number;
304   read?: boolean;
305   auth?: string;
306 }
307
308 export interface UserMentionResponse {
309   op: string;
310   mention: Comment;
311 }
312
313 export interface BanFromCommunityForm {
314   community_id: number;
315   user_id: number;
316   ban: boolean;
317   reason?: string;
318   expires?: number;
319   auth?: string;
320 }
321
322 export interface BanFromCommunityResponse {
323   op: string;
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   op: string;
348   moderators: Array<CommunityUser>;
349 }
350
351 export interface GetModlogForm {
352   mod_user_id?: number;
353   community_id?: number;
354   page?: number;
355   limit?: number;
356 }
357
358 export interface GetModlogResponse {
359   op: string;
360   removed_posts: Array<ModRemovePost>;
361   locked_posts: Array<ModLockPost>;
362   stickied_posts: Array<ModStickyPost>;
363   removed_comments: Array<ModRemoveComment>;
364   removed_communities: Array<ModRemoveCommunity>;
365   banned_from_community: Array<ModBanFromCommunity>;
366   banned: Array<ModBan>;
367   added_to_community: Array<ModAddCommunity>;
368   added: Array<ModAdd>;
369 }
370
371 export interface ModRemovePost {
372   id: number;
373   mod_user_id: number;
374   post_id: number;
375   reason?: string;
376   removed?: boolean;
377   when_: string;
378   mod_user_name: string;
379   post_name: string;
380   community_id: number;
381   community_name: string;
382 }
383
384 export interface ModLockPost {
385   id: number;
386   mod_user_id: number;
387   post_id: number;
388   locked?: boolean;
389   when_: string;
390   mod_user_name: string;
391   post_name: string;
392   community_id: number;
393   community_name: string;
394 }
395
396 export interface ModStickyPost {
397   id: number;
398   mod_user_id: number;
399   post_id: number;
400   stickied?: boolean;
401   when_: string;
402   mod_user_name: string;
403   post_name: string;
404   community_id: number;
405   community_name: string;
406 }
407
408 export interface ModRemoveComment {
409   id: number;
410   mod_user_id: number;
411   comment_id: number;
412   reason?: string;
413   removed?: boolean;
414   when_: string;
415   mod_user_name: string;
416   comment_user_id: number;
417   comment_user_name: string;
418   comment_content: string;
419   post_id: number;
420   post_name: string;
421   community_id: number;
422   community_name: string;
423 }
424
425 export interface ModRemoveCommunity {
426   id: number;
427   mod_user_id: number;
428   community_id: number;
429   reason?: string;
430   removed?: boolean;
431   expires?: number;
432   when_: string;
433   mod_user_name: string;
434   community_name: string;
435 }
436
437 export interface ModBanFromCommunity {
438   id: number;
439   mod_user_id: number;
440   other_user_id: number;
441   community_id: number;
442   reason?: string;
443   banned?: boolean;
444   expires?: number;
445   when_: string;
446   mod_user_name: string;
447   other_user_name: string;
448   community_name: string;
449 }
450
451 export interface ModBan {
452   id: number;
453   mod_user_id: number;
454   other_user_id: number;
455   reason?: string;
456   banned?: boolean;
457   expires?: number;
458   when_: string;
459   mod_user_name: string;
460   other_user_name: string;
461 }
462
463 export interface ModAddCommunity {
464   id: number;
465   mod_user_id: number;
466   other_user_id: number;
467   community_id: number;
468   removed?: boolean;
469   when_: string;
470   mod_user_name: string;
471   other_user_name: string;
472   community_name: string;
473 }
474
475 export interface ModAdd {
476   id: number;
477   mod_user_id: number;
478   other_user_id: number;
479   removed?: boolean;
480   when_: string;
481   mod_user_name: string;
482   other_user_name: string;
483 }
484
485 export interface LoginForm {
486   username_or_email: string;
487   password: string;
488 }
489
490 export interface RegisterForm {
491   username: string;
492   email?: string;
493   password: string;
494   password_verify: string;
495   admin: boolean;
496   show_nsfw: boolean;
497 }
498
499 export interface LoginResponse {
500   op: string;
501   jwt: string;
502 }
503
504 export interface UserSettingsForm {
505   show_nsfw: boolean;
506   theme: string;
507   default_sort_type: SortType;
508   default_listing_type: ListingType;
509   lang: string;
510   avatar?: string;
511   email?: string;
512   matrix_user_id?: string;
513   new_password?: string;
514   new_password_verify?: string;
515   old_password?: string;
516   show_avatars: boolean;
517   send_notifications_to_email: boolean;
518   auth: string;
519 }
520
521 export interface CommunityForm {
522   name: string;
523   title: string;
524   description?: string;
525   category_id: number;
526   edit_id?: number;
527   removed?: boolean;
528   deleted?: boolean;
529   nsfw: boolean;
530   reason?: string;
531   expires?: number;
532   auth?: string;
533 }
534
535 export interface GetCommunityResponse {
536   op: string;
537   community: Community;
538   moderators: Array<CommunityUser>;
539   admins: Array<UserView>;
540 }
541
542 export interface CommunityResponse {
543   op: string;
544   community: Community;
545 }
546
547 export interface ListCommunitiesForm {
548   sort: string;
549   page?: number;
550   limit?: number;
551   auth?: string;
552 }
553
554 export interface ListCommunitiesResponse {
555   op: string;
556   communities: Array<Community>;
557 }
558
559 export interface ListCategoriesResponse {
560   op: string;
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 GetPostResponse {
589   op: string;
590   post: Post;
591   comments: Array<Comment>;
592   community: Community;
593   moderators: Array<CommunityUser>;
594   admins: Array<UserView>;
595 }
596
597 export interface SavePostForm {
598   post_id: number;
599   save: boolean;
600   auth?: string;
601 }
602
603 export interface PostResponse {
604   op: string;
605   post: Post;
606 }
607
608 export interface CommentForm {
609   content: string;
610   post_id: number;
611   parent_id?: number;
612   edit_id?: number;
613   creator_id: number;
614   removed?: boolean;
615   deleted?: boolean;
616   reason?: string;
617   read?: boolean;
618   auth: string;
619 }
620
621 export interface SaveCommentForm {
622   comment_id: number;
623   save: boolean;
624   auth?: string;
625 }
626
627 export interface CommentResponse {
628   op: string;
629   comment: Comment;
630 }
631
632 export interface CommentLikeForm {
633   comment_id: number;
634   post_id: number;
635   score: number;
636   auth?: string;
637 }
638
639 export interface CommentNode {
640   comment: Comment;
641   children?: Array<CommentNode>;
642 }
643
644 export interface GetPostsForm {
645   type_: string;
646   sort: string;
647   page?: number;
648   limit?: number;
649   community_id?: number;
650   auth?: string;
651 }
652
653 export interface GetPostsResponse {
654   op: string;
655   posts: Array<Post>;
656 }
657
658 export interface CreatePostLikeForm {
659   post_id: number;
660   score: number;
661   auth?: string;
662 }
663
664 export interface CreatePostLikeResponse {
665   op: string;
666   post: Post;
667 }
668
669 export interface SiteForm {
670   name: string;
671   description?: string;
672   enable_downvotes: boolean;
673   open_registration: boolean;
674   enable_nsfw: boolean;
675   auth?: string;
676 }
677
678 export interface GetSiteResponse {
679   op: string;
680   site: Site;
681   admins: Array<UserView>;
682   banned: Array<UserView>;
683   online: number;
684 }
685
686 export interface SiteResponse {
687   op: string;
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   op: string;
701   user: UserView;
702   banned: boolean;
703 }
704
705 export interface AddAdminForm {
706   user_id: number;
707   added: boolean;
708   auth?: string;
709 }
710
711 export interface AddAdminResponse {
712   op: string;
713   admins: Array<UserView>;
714 }
715
716 export interface SearchForm {
717   q: string;
718   type_: string;
719   community_id?: number;
720   sort: string;
721   page?: number;
722   limit?: number;
723   auth?: string;
724 }
725
726 export interface SearchResponse {
727   op: string;
728   type_: string;
729   posts?: Array<Post>;
730   comments?: Array<Comment>;
731   communities: Array<Community>;
732   users: Array<UserView>;
733 }
734
735 export interface DeleteAccountForm {
736   password: string;
737 }
738
739 export interface PasswordResetForm {
740   email: string;
741 }
742
743 export interface PasswordResetResponse {
744   op: string;
745 }
746
747 export interface PasswordChangeForm {
748   token: string;
749   password: string;
750   password_verify: string;
751 }
752
753 export interface PrivateMessageForm {
754   content: string;
755   recipient_id: number;
756   auth?: string;
757 }
758
759 export interface PrivateMessageFormParams {
760   recipient_id: number;
761 }
762
763 export interface EditPrivateMessageForm {
764   edit_id: number;
765   content?: string;
766   deleted?: boolean;
767   read?: boolean;
768   auth?: string;
769 }
770
771 export interface GetPrivateMessagesForm {
772   unread_only: boolean;
773   page?: number;
774   limit?: number;
775   auth?: string;
776 }
777
778 export interface PrivateMessagesResponse {
779   op: string;
780   messages: Array<PrivateMessage>;
781 }
782
783 export interface PrivateMessageResponse {
784   op: string;
785   message: PrivateMessage;
786 }