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