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