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