]> Untitled Git - lemmy.git/blob - ui/src/interfaces.ts
Adding ability to do mod action on post creator
[lemmy.git] / ui / src / interfaces.ts
1 export enum UserOperation {
2   Login, Register, CreateCommunity, CreatePost, ListCommunities, ListCategories, GetPost, GetCommunity, CreateComment, EditComment, SaveComment, CreateCommentLike, GetPosts, CreatePostLike, EditPost, SavePost, EditCommunity, FollowCommunity, GetFollowedCommunities, GetUserDetails, GetReplies, GetModlog, BanFromCommunity, AddModToCommunity, CreateSite, EditSite, GetSite, AddAdmin, BanUser, Search, MarkAllAsRead, SaveUserSettings, TransferCommunity, TransferSite
3 }
4
5 export enum CommentSortType {
6   Hot, Top, New
7 }
8
9 export enum ListingType {
10   All, Subscribed, Community
11 }
12
13 export enum SortType {
14   Hot, New, TopDay, TopWeek, TopMonth, TopYear, TopAll
15 }
16
17 export enum SearchType {
18   All, Comments, Posts, Communities, Users, Url
19 }
20
21 export interface User {
22   id: number;
23   iss: string;
24   username: string;
25   show_nsfw: boolean;
26 }
27
28 export interface UserView {
29   id: number;
30   name: string;
31   fedi_name: string;
32   published: string;
33   number_of_posts: number;
34   post_score: number;
35   number_of_comments: number;
36   comment_score: number;
37   banned: boolean;
38 }
39
40 export interface CommunityUser {
41   id: number;
42   user_id: number;
43   user_name: string;
44   community_id: number;
45   community_name: string;
46   published: string;
47 }
48
49 export interface Community {
50   id: number;
51   name: string;
52   title: string;
53   description?: string;
54   category_id: number;
55   creator_id: number;
56   removed: boolean;
57   deleted: boolean;
58   nsfw: boolean;
59   published: string;
60   updated?: string;
61   creator_name: string;
62   category_name: string;
63   number_of_subscribers: number;
64   number_of_posts: number;
65   number_of_comments: number;
66   user_id?: number;
67   subscribed?: boolean;
68 }
69
70 export interface Post {
71   id: number;
72   name: string;
73   url?: string;
74   body?: string;
75   creator_id: number;
76   community_id: number;
77   removed: boolean;
78   deleted: boolean;
79   locked: boolean;
80   nsfw: boolean;
81   banned: boolean;
82   banned_from_community: boolean;
83   published: string;
84   updated?: string;
85   creator_name: string;
86   community_name: string;
87   community_removed: boolean;
88   community_deleted: boolean;
89   community_nsfw: boolean;
90   number_of_comments: number;
91   score: number;
92   upvotes: number;
93   downvotes: number;
94   hot_rank: number;
95   user_id?: number;
96   my_vote?: number;
97   subscribed?: boolean;
98   read?: boolean;
99   saved?: boolean;
100 }
101
102 export interface Comment {
103   id: number;
104   creator_id: number;
105   post_id: number,
106   parent_id?: number;
107   content: string;
108   removed: boolean;
109   deleted: boolean;
110   read: boolean;
111   published: string;
112   updated?: string;
113   community_id: number,
114   banned: boolean;
115   banned_from_community: boolean;
116   creator_name: string;
117   score: number;
118   upvotes: number;
119   downvotes: number;
120   user_id?: number;
121   my_vote?: number;
122   saved?: boolean;
123 }
124
125 export interface Category {
126   id: number;
127   name: string;
128 }
129
130 export interface Site {
131   id: number;
132   name: string;
133   description?: string;
134   creator_id: number;
135   published: string;
136   updated?: string;
137   creator_name: string;
138   number_of_users: number;
139   number_of_posts: number;
140   number_of_comments: number;
141   number_of_communities: number;
142 }
143
144 export enum BanType {Community, Site};
145
146 export interface FollowCommunityForm {
147   community_id: number;
148   follow: boolean;
149   auth?: string;
150 }
151
152 export interface GetFollowedCommunitiesResponse {
153   op: string;
154   communities: Array<CommunityUser>;
155 }
156
157 export interface GetUserDetailsForm {
158   user_id?: number;
159   username?: string;
160   sort: string;
161   page?: number;
162   limit?: number;
163   community_id?: number;
164   saved_only: boolean;
165 }
166
167 export interface UserDetailsResponse {
168   op: string;
169   user: UserView;
170   follows: Array<CommunityUser>;
171   moderates: Array<CommunityUser>;
172   comments: Array<Comment>;
173   posts: Array<Post>;
174 }
175
176 export interface GetRepliesForm {
177   sort: string; // TODO figure this one out
178   page?: number;
179   limit?: number;
180   unread_only: boolean;
181   auth?: string;
182 }
183
184 export interface GetRepliesResponse {
185   op: string;
186   replies: Array<Comment>;
187 }
188
189 export interface BanFromCommunityForm {
190   community_id: number;
191   user_id: number;
192   ban: boolean;
193   reason?: string,
194   expires?: number,
195   auth?: string;
196 }
197
198 export interface BanFromCommunityResponse {
199   op: string;
200   user: UserView,
201   banned: boolean,
202 }
203
204 export interface AddModToCommunityForm {
205   community_id: number;
206   user_id: number;
207   added: boolean;
208   auth?: string;
209 }
210
211 export interface TransferCommunityForm {
212   community_id: number;
213   user_id: number;
214   auth?: string;
215 }
216
217 export interface TransferSiteForm {
218   user_id: number;
219   auth?: string;
220 }
221
222 export interface AddModToCommunityResponse {
223   op: string;
224   moderators: Array<CommunityUser>;
225 }
226
227 export interface GetModlogForm {
228   mod_user_id?: number;
229   community_id?: number;
230   page?: number;
231   limit?: number;
232 }
233
234 export interface GetModlogResponse {
235   op: string;
236   removed_posts: Array<ModRemovePost>,
237   locked_posts: Array<ModLockPost>,
238   removed_comments: Array<ModRemoveComment>,
239   removed_communities: Array<ModRemoveCommunity>,
240   banned_from_community: Array<ModBanFromCommunity>,
241   banned: Array<ModBan>,
242   added_to_community: Array<ModAddCommunity>,
243   added: Array<ModAdd>,
244 }
245
246 export interface ModRemovePost {
247   id: number;
248   mod_user_id: number;
249   post_id: number;
250   reason?: string;
251   removed?: boolean;
252   when_: string
253   mod_user_name: string;
254   post_name: string;
255   community_id: number;
256   community_name: string;
257 }
258
259 export interface ModLockPost {
260   id: number,
261   mod_user_id: number,
262   post_id: number,
263   locked?: boolean,
264   when_: string,
265   mod_user_name: string,
266   post_name: string,
267   community_id: number,
268   community_name: string,
269 }
270
271 export interface ModRemoveComment {
272   id: number,
273   mod_user_id: number,
274   comment_id: number,
275   reason?: string,
276   removed?: boolean,
277   when_: string,
278   mod_user_name: string,
279   comment_user_id: number,
280   comment_user_name: string,
281   comment_content: string,
282   post_id: number,
283   post_name: string,
284   community_id: number,
285   community_name: string,
286 }
287
288 export interface ModRemoveCommunity {
289   id: number,
290   mod_user_id: number,
291   community_id: number,
292   reason?: string,
293   removed?: boolean,
294   expires?: number,
295   when_: string,
296   mod_user_name: string,
297   community_name: string,
298 }
299
300 export interface ModBanFromCommunity {
301   id: number,
302   mod_user_id: number,
303   other_user_id: number,
304   community_id: number,
305   reason?: string,
306   banned?: boolean,
307   expires?: number,
308   when_: string,
309   mod_user_name: string,
310   other_user_name: string,
311   community_name: string,
312 }
313
314 export interface ModBan {
315   id: number,
316   mod_user_id: number,
317   other_user_id: number,
318   reason?: string,
319   banned?: boolean,
320   expires?: number,
321   when_: string,
322   mod_user_name: string,
323   other_user_name: string,
324 }
325
326 export interface ModAddCommunity {
327   id: number,
328   mod_user_id: number,
329   other_user_id: number,
330   community_id: number,
331   removed?: boolean,
332   when_: string,
333   mod_user_name: string,
334   other_user_name: string,
335   community_name: string,
336 }
337
338 export interface ModAdd {
339   id: number,
340   mod_user_id: number,
341   other_user_id: number,
342   removed?: boolean,
343   when_: string,
344   mod_user_name: string,
345   other_user_name: string,
346 }
347
348 export interface LoginForm {
349   username_or_email: string;
350   password: string;
351 }
352
353 export interface RegisterForm {
354   username: string;
355   email?: string;
356   password: string;
357   password_verify: string;
358   admin: boolean;
359   show_nsfw: boolean;
360 }
361
362 export interface LoginResponse {
363   op: string;
364   jwt: string;
365 }
366
367 export interface UserSettingsForm {
368   show_nsfw: boolean;
369   auth: string;
370 }
371
372 export interface CommunityForm {
373   name: string;
374   title: string;
375   description?: string,
376   category_id: number,
377   edit_id?: number;
378   removed?: boolean;
379   deleted?: boolean;
380   nsfw: boolean;
381   reason?: string;
382   expires?: number;
383   auth?: string;
384 }
385
386 export interface GetCommunityResponse {
387   op: string;
388   community: Community;
389   moderators: Array<CommunityUser>;
390   admins: Array<UserView>;
391 }
392
393
394 export interface CommunityResponse {
395   op: string;
396   community: Community;
397 }
398
399 export interface ListCommunitiesForm {
400   sort: string;
401   page?: number;
402   limit?: number;
403   auth?: string;
404 }
405
406 export interface ListCommunitiesResponse {
407   op: string;
408   communities: Array<Community>;
409 }
410
411 export interface ListCategoriesResponse {
412   op: string;
413   categories: Array<Category>;
414 }
415
416 export interface PostForm {
417   name: string;
418   url?: string;
419   body?: string;
420   community_id: number;
421   updated?: number;
422   edit_id?: number;
423   creator_id: number;
424   removed?: boolean;
425   deleted?: boolean;
426   nsfw: boolean;
427   locked?: boolean;
428   reason?: string;
429   auth: string;
430 }
431
432 export interface PostFormParams {
433   name: string;
434   url?: string;
435   body?: string;
436   community?: string;
437 }
438
439 export interface GetPostResponse {
440   op: string;
441   post: Post;
442   comments: Array<Comment>;
443   community: Community;
444   moderators: Array<CommunityUser>;
445   admins: Array<UserView>;
446 }
447
448 export interface SavePostForm {
449   post_id: number;
450   save: boolean;
451   auth?: string;
452 }
453
454 export interface PostResponse {
455   op: string;
456   post: Post;
457 }
458
459 export interface CommentForm {
460   content: string;
461   post_id: number;
462   parent_id?: number;
463   edit_id?: number;
464   creator_id: number;
465   removed?: boolean;
466   deleted?: boolean;
467   reason?: string;
468   read?: boolean;
469   auth: string;
470 }
471
472 export interface SaveCommentForm {
473   comment_id: number;
474   save: boolean;
475   auth?: string;
476 }
477
478 export interface CommentResponse {
479   op: string;
480   comment: Comment;
481 }
482
483 export interface CommentLikeForm {
484   comment_id: number;
485   post_id: number;
486   score: number;
487   auth?: string;
488 }
489
490 export interface CommentNode {
491   comment: Comment;
492   children?: Array<CommentNode>;
493 }
494
495 export interface GetPostsForm {
496   type_: string;
497   sort: string;
498   page?: number;
499   limit?: number;
500   community_id?: number;
501   auth?: string;
502 }
503
504 export interface GetPostsResponse {
505   op: string;
506   posts: Array<Post>;
507 }
508
509 export interface CreatePostLikeForm {
510   post_id: number;
511   score: number;
512   auth?: string;
513 }
514
515 export interface CreatePostLikeResponse {
516   op: string;
517   post: Post;
518 }
519
520 export interface SiteForm {
521   name: string;
522   description?: string,
523   removed?: boolean;
524   reason?: string;
525   expires?: number;
526   auth?: string;
527 }
528
529 export interface GetSiteResponse {
530   op: string;
531   site: Site;
532   admins: Array<UserView>;
533   banned: Array<UserView>;
534 }
535
536
537 export interface SiteResponse {
538   op: string;
539   site: Site;
540 }
541
542 export interface BanUserForm {
543   user_id: number;
544   ban: boolean;
545   reason?: string,
546   expires?: number,
547   auth?: string;
548 }
549
550 export interface BanUserResponse {
551   op: string;
552   user: UserView,
553   banned: boolean,
554 }
555
556 export interface AddAdminForm {
557   user_id: number;
558   added: boolean;
559   auth?: string;
560 }
561
562 export interface AddAdminResponse {
563   op: string;
564   admins: Array<UserView>;
565 }
566
567 export interface SearchForm {
568   q: string;
569   type_: string;
570   community_id?: number;
571   sort: string;
572   page?: number;
573   limit?: number;
574 }
575
576 export interface SearchResponse {
577   op: string;
578   type_: string;
579   posts?: Array<Post>;
580   comments?: Array<Comment>;
581   communities: Array<Community>;  
582   users: Array<UserView>;
583 }