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