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