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