-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathhttp.ts
2566 lines (2415 loc) · 62.9 KB
/
http.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import {
Body,
Controller,
Get,
Post,
Put,
Queries,
Route,
Inject,
UploadedFile,
Delete,
Security,
Tags,
} from "tsoa";
import {
DeleteImageParamsI,
GetCommentI,
GetCommentsI,
GetCommunityI,
GetCommunityPendingFollowsCountI,
GetModlogI,
GetPersonDetailsI,
GetPostI,
GetPostsI,
GetRandomCommunityI,
GetRegistrationApplicationI,
GetReportCountI,
GetSiteMetadataI,
ListBannedPersonsI,
ListCommentLikesI,
ListCommunitiesI,
ListCommunityPendingFollowsI,
ListCustomEmojisI,
ListInboxI,
ListMediaI,
ListPersonContentI,
ListPersonSavedI,
ListPostLikesI,
ListRegistrationApplicationsI,
ListReportsI,
ListTaglinesI,
ResolveObjectI,
SearchI,
UploadImage,
VERSION,
} from "./other_types";
import { AddAdmin } from "./types/AddAdmin";
import { AddAdminResponse } from "./types/AddAdminResponse";
import { AddModToCommunity } from "./types/AddModToCommunity";
import { AddModToCommunityResponse } from "./types/AddModToCommunityResponse";
import { ApproveRegistrationApplication } from "./types/ApproveRegistrationApplication";
import { BanFromCommunity } from "./types/BanFromCommunity";
import { BanFromCommunityResponse } from "./types/BanFromCommunityResponse";
import { MarkManyPostsAsRead } from "./types/MarkManyPostsAsRead";
import { BanPerson } from "./types/BanPerson";
import { BanPersonResponse } from "./types/BanPersonResponse";
import { BannedPersonsResponse } from "./types/BannedPersonsResponse";
import { BlockCommunity } from "./types/BlockCommunity";
import { BlockCommunityResponse } from "./types/BlockCommunityResponse";
import { BlockPerson } from "./types/BlockPerson";
import { BlockPersonResponse } from "./types/BlockPersonResponse";
import { ChangePassword } from "./types/ChangePassword";
import { CommentReportResponse } from "./types/CommentReportResponse";
import { CommentResponse } from "./types/CommentResponse";
import { CommunityResponse } from "./types/CommunityResponse";
import { CreateComment } from "./types/CreateComment";
import { CreateCommentLike } from "./types/CreateCommentLike";
import { CreateCommentReport } from "./types/CreateCommentReport";
import { CreateCommunity } from "./types/CreateCommunity";
import { CreateCustomEmoji } from "./types/CreateCustomEmoji";
import { CreateOAuthProvider } from "./types/CreateOAuthProvider";
import { CreatePost } from "./types/CreatePost";
import { CreatePostLike } from "./types/CreatePostLike";
import { CreatePostReport } from "./types/CreatePostReport";
import { CreatePrivateMessage } from "./types/CreatePrivateMessage";
import { CreatePrivateMessageReport } from "./types/CreatePrivateMessageReport";
import { CreateSite } from "./types/CreateSite";
import { CustomEmojiResponse } from "./types/CustomEmojiResponse";
import { DeleteAccount } from "./types/DeleteAccount";
import { DeleteComment } from "./types/DeleteComment";
import { DeleteCommunity } from "./types/DeleteCommunity";
import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
import { DeleteOAuthProvider } from "./types/DeleteOAuthProvider";
import { DeletePost } from "./types/DeletePost";
import { DeletePrivateMessage } from "./types/DeletePrivateMessage";
import { DistinguishComment } from "./types/DistinguishComment";
import { EditComment } from "./types/EditComment";
import { EditCommunity } from "./types/EditCommunity";
import { EditCustomEmoji } from "./types/EditCustomEmoji";
import { EditOAuthProvider } from "./types/EditOAuthProvider";
import { EditPost } from "./types/EditPost";
import { EditPrivateMessage } from "./types/EditPrivateMessage";
import { EditSite } from "./types/EditSite";
import { OAuthProvider } from "./types/OAuthProvider";
import { FeaturePost } from "./types/FeaturePost";
import { FollowCommunity } from "./types/FollowCommunity";
import { GetCaptchaResponse } from "./types/GetCaptchaResponse";
import { GetComment } from "./types/GetComment";
import { GetComments } from "./types/GetComments";
import { GetCommentsResponse } from "./types/GetCommentsResponse";
import { GetCommunity } from "./types/GetCommunity";
import { GetCommunityResponse } from "./types/GetCommunityResponse";
import { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse";
import { GetModlog } from "./types/GetModlog";
import { GetModlogResponse } from "./types/GetModlogResponse";
import { GetPersonDetails } from "./types/GetPersonDetails";
import { GetPersonDetailsResponse } from "./types/GetPersonDetailsResponse";
import { GetPost } from "./types/GetPost";
import { GetPostResponse } from "./types/GetPostResponse";
import { GetPosts } from "./types/GetPosts";
import { GetPostsResponse } from "./types/GetPostsResponse";
import { GetReportCount } from "./types/GetReportCount";
import { GetReportCountResponse } from "./types/GetReportCountResponse";
import { GetSiteMetadata } from "./types/GetSiteMetadata";
import { GetSiteMetadataResponse } from "./types/GetSiteMetadataResponse";
import { GetSiteResponse } from "./types/GetSiteResponse";
import { GetUnreadCountResponse } from "./types/GetUnreadCountResponse";
import { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse";
import { ListCommunities } from "./types/ListCommunities";
import { ListCommunitiesResponse } from "./types/ListCommunitiesResponse";
import { ListRegistrationApplications } from "./types/ListRegistrationApplications";
import { ListRegistrationApplicationsResponse } from "./types/ListRegistrationApplicationsResponse";
import { LockPost } from "./types/LockPost";
import { Login } from "./types/Login";
import { LoginResponse } from "./types/LoginResponse";
import { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead";
import { MarkPostAsRead } from "./types/MarkPostAsRead";
import { MarkPrivateMessageAsRead } from "./types/MarkPrivateMessageAsRead";
import { PasswordChangeAfterReset } from "./types/PasswordChangeAfterReset";
import { PasswordReset } from "./types/PasswordReset";
import { PostReportResponse } from "./types/PostReportResponse";
import { PostResponse } from "./types/PostResponse";
import { PrivateMessageReportResponse } from "./types/PrivateMessageReportResponse";
import { PrivateMessageResponse } from "./types/PrivateMessageResponse";
import { PurgeComment } from "./types/PurgeComment";
import { PurgeCommunity } from "./types/PurgeCommunity";
import { PurgePerson } from "./types/PurgePerson";
import { PurgePost } from "./types/PurgePost";
import { Register } from "./types/Register";
import { RegistrationApplicationResponse } from "./types/RegistrationApplicationResponse";
import { RemoveComment } from "./types/RemoveComment";
import { RemoveCommunity } from "./types/RemoveCommunity";
import { RemovePost } from "./types/RemovePost";
import { ResolveCommentReport } from "./types/ResolveCommentReport";
import { ResolveObject } from "./types/ResolveObject";
import { ResolveObjectResponse } from "./types/ResolveObjectResponse";
import { ResolvePostReport } from "./types/ResolvePostReport";
import { ResolvePrivateMessageReport } from "./types/ResolvePrivateMessageReport";
import { SaveComment } from "./types/SaveComment";
import { SavePost } from "./types/SavePost";
import { SaveUserSettings } from "./types/SaveUserSettings";
import { Search } from "./types/Search";
import { SearchResponse } from "./types/SearchResponse";
import { SiteResponse } from "./types/SiteResponse";
import { TransferCommunity } from "./types/TransferCommunity";
import { VerifyEmail } from "./types/VerifyEmail";
import { HideCommunity } from "./types/HideCommunity";
import { GenerateTotpSecretResponse } from "./types/GenerateTotpSecretResponse";
import { UpdateTotp } from "./types/UpdateTotp";
import { UpdateTotpResponse } from "./types/UpdateTotpResponse";
import { SuccessResponse } from "./types/SuccessResponse";
import { LoginToken } from "./types/LoginToken";
import { ListPostLikes } from "./types/ListPostLikes";
import { ListPostLikesResponse } from "./types/ListPostLikesResponse";
import { ListCommentLikes } from "./types/ListCommentLikes";
import { ListCommentLikesResponse } from "./types/ListCommentLikesResponse";
import { HidePost } from "./types/HidePost";
import { ListMedia } from "./types/ListMedia";
import { ListMediaResponse } from "./types/ListMediaResponse";
import { AuthenticateWithOauth } from "./types/AuthenticateWithOauth";
import { GetRegistrationApplication } from "./types/GetRegistrationApplication";
import { CreateTagline } from "./types/CreateTagline";
import { TaglineResponse } from "./types/TaglineResponse";
import { UpdateTagline } from "./types/UpdateTagline";
import { DeleteTagline } from "./types/DeleteTagline";
import { ListTaglines } from "./types/ListTaglines";
import { ListTaglinesResponse } from "./types/ListTaglinesResponse";
import { ListCustomEmojis } from "./types/ListCustomEmojis";
import { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse";
import { GetRandomCommunity } from "./types/GetRandomCommunity";
import { ApproveCommunityPendingFollower } from "./types/ApproveCommunityPendingFollower";
import { GetCommunityPendingFollowsCount } from "./types/GetCommunityPendingFollowsCount";
import { GetCommunityPendingFollowsCountResponse } from "./types/GetCommunityPendingFollowsCountResponse";
import { ListCommunityPendingFollowsResponse } from "./types/ListCommunityPendingFollowsResponse";
import { ListCommunityPendingFollows } from "./types/ListCommunityPendingFollows";
import { ListReports } from "./types/ListReports";
import { ListReportsResponse } from "./types/ListReportsResponse";
import { MyUserInfo } from "./types/MyUserInfo";
import { UserBlockInstanceParams } from "./types/UserBlockInstanceParams";
import { AdminAllowInstanceParams } from "./types/AdminAllowInstanceParams";
import { AdminBlockInstanceParams } from "./types/AdminBlockInstanceParams";
import { ListPersonContent } from "./types/ListPersonContent";
import { ListPersonContentResponse } from "./types/ListPersonContentResponse";
import { ListPersonSaved } from "./types/ListPersonSaved";
import { ListPersonSavedResponse } from "./types/ListPersonSavedResponse";
import { DeleteImageParams } from "./types/DeleteImageParams";
import { UploadImageResponse } from "./types/UploadImageResponse";
import { ListInboxResponse } from "./types/ListInboxResponse";
import { ListInbox } from "./types/ListInbox";
import { MarkPersonCommentMentionAsRead } from "./types/MarkPersonCommentMentionAsRead";
import { MarkPersonPostMentionAsRead } from "./types/MarkPersonPostMentionAsRead";
import { GetCommentsSlimResponse } from "./types/GetCommentsSlimResponse";
import { ResendVerificationEmail } from "./types/ResendVerificationEmail";
import { ListBannedPersons } from "./types/ListBannedPersons";
enum HttpType {
Get = "GET",
Post = "POST",
Put = "PUT",
Delete = "DELETE",
}
type RequestOptions = Pick<RequestInit, "signal">;
/**
* Helps build lemmy HTTP requests.
*/
@Route("api/v4")
export class LemmyHttp extends Controller {
#apiUrl: string;
#headers: { [key: string]: string } = {};
#fetchFunction: typeof fetch = fetch.bind(globalThis);
/**
* Generates a new instance of LemmyHttp.
* @param baseUrl the base url, without the vX version: https://lemmy.ml -> goes to https://lemmy.ml/api/vX
* @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` .
*/
constructor(
baseUrl: string,
options?: {
fetchFunction?: typeof fetch;
headers?: { [key: string]: string };
},
) {
super();
this.#apiUrl = `${baseUrl.replace(/\/+$/, "")}/api/${VERSION}`;
if (options?.headers) {
this.#headers = options.headers;
}
if (options?.fetchFunction) {
this.#fetchFunction = options.fetchFunction;
}
}
/**
* @summary Gets the site, and your user data.
*/
@Security("bearerAuth")
@Security({})
@Get("/site")
@Tags("Site")
getSite(@Inject() options?: RequestOptions) {
return this.#wrapper<object, GetSiteResponse>(
HttpType.Get,
"/site",
{},
options,
);
}
/**
* @summary Create your site.
*/
@Security("bearerAuth")
@Post("/site")
@Tags("Site")
createSite(@Body() form: CreateSite, @Inject() options?: RequestOptions) {
return this.#wrapper<CreateSite, SiteResponse>(
HttpType.Post,
"/site",
form,
options,
);
}
/**
* @summary Edit your site.
*/
@Security("bearerAuth")
@Put("/site")
@Tags("Site")
editSite(@Body() form: EditSite, @Inject() options?: RequestOptions) {
return this.#wrapper<EditSite, SiteResponse>(
HttpType.Put,
"/site",
form,
options,
);
}
/**
* @summary Leave the Site admins.
*/
@Security("bearerAuth")
@Post("/admin/leave")
@Tags("Admin")
leaveAdmin(@Inject() options?: RequestOptions) {
return this.#wrapper<object, GetSiteResponse>(
HttpType.Post,
"/admin/leave",
{},
options,
);
}
/**
* @summary Generate a TOTP / two-factor secret.
*
* Generate a TOTP / two-factor secret.
* Afterwards you need to call `/account/auth/totp/update` with a valid token to enable it.
*/
@Security("bearerAuth")
@Post("/account/auth/totp/generate")
@Tags("Account")
generateTotpSecret(@Inject() options?: RequestOptions) {
return this.#wrapper<object, GenerateTotpSecretResponse>(
HttpType.Post,
"/account/auth/totp/generate",
{},
options,
);
}
/**
* @summary Get data of current user.
*/
@Security("bearerAuth")
@Get("/account")
@Tags("Account")
getMyUser(@Inject() options?: RequestOptions) {
return this.#wrapper<object, MyUserInfo>(
HttpType.Get,
"/account",
{},
options,
);
}
/**
* @summary Export a backup of your user settings.
*
* Export a backup of your user settings, including your saved content,
* followed communities, and blocks.
*/
@Security("bearerAuth")
@Get("/account/settings/export")
@Tags("Account")
exportSettings(@Inject() options?: RequestOptions) {
return this.#wrapper<object, string>(
HttpType.Get,
"/account/settings/export",
{},
options,
);
}
/**
* @summary Import a backup of your user settings.
*/
@Security("bearerAuth")
@Post("/account/settings/import")
@Tags("Account")
importSettings(@Body() form: any, @Inject() options?: RequestOptions) {
return this.#wrapper<object, SuccessResponse>(
HttpType.Post,
"/account/settings/import",
form,
options,
);
}
/**
* @summary List login tokens for your user
*/
@Security("bearerAuth")
@Get("/account/list_logins")
@Tags("Account")
listLogins(@Inject() options?: RequestOptions) {
return this.#wrapper<object, LoginToken[]>(
HttpType.Get,
"/account/list_logins",
{},
options,
);
}
/**
* @summary Returns an error message if your auth token is invalid
*/
@Security("bearerAuth")
@Get("/account/validate_auth")
@Tags("Account")
validateAuth(@Inject() options?: RequestOptions) {
return this.#wrapper<object, SuccessResponse>(
HttpType.Get,
"/account/validate_auth",
{},
options,
);
}
/**
* @summary List all the media for your user
*/
@Security("bearerAuth")
@Get("/account/list_media")
@Tags("Account", "Media")
listMedia(
@Queries() form: ListMediaI = {},
@Inject() options?: RequestOptions,
) {
return this.#wrapper<ListMedia, ListMediaResponse>(
HttpType.Get,
"/account/list_media",
form,
options,
);
}
/**
* @summary List all the media known to your instance.
*/
@Security("bearerAuth")
@Get("/admin/list_all_media")
@Tags("Admin", "Media")
listAllMedia(
@Queries() form: ListMediaI = {},
@Inject() options?: RequestOptions,
) {
return this.#wrapper<ListMedia, ListMediaResponse>(
HttpType.Get,
"/admin/list_all_media",
form,
options,
);
}
/**
* @summary Enable / Disable TOTP / two-factor authentication.
*
* To enable, you need to first call `/account/auth/totp/generate` and then pass a valid token to this.
*
* Disabling is only possible if 2FA was previously enabled. Again it is necessary to pass a valid token.
*/
@Security("bearerAuth")
@Post("/account/auth/totp/update")
@Tags("Account")
updateTotp(@Body() form: UpdateTotp, @Inject() options?: RequestOptions) {
return this.#wrapper<UpdateTotp, UpdateTotpResponse>(
HttpType.Post,
"/account/auth/totp/update",
form,
options,
);
}
/**
* @summary Get the modlog.
*/
@Security("bearerAuth")
@Security({})
@Get("/modlog")
@Tags("Miscellaneous")
getModlog(
@Queries() form: GetModlogI = {},
@Inject() options?: RequestOptions,
) {
return this.#wrapper<GetModlog, GetModlogResponse>(
HttpType.Get,
"/modlog",
form,
options,
);
}
/**
* @summary Search lemmy.
*/
@Security("bearerAuth")
@Security({})
@Get("/search")
@Tags("Miscellaneous")
search(@Queries() form: SearchI, @Inject() options?: RequestOptions) {
return this.#wrapper<Search, SearchResponse>(
HttpType.Get,
"/search",
form,
options,
);
}
/**
* @summary Fetch a non-local / federated object.
*/
@Security("bearerAuth")
@Security({})
@Get("/resolve_object")
@Tags("Miscellaneous")
resolveObject(
@Queries() form: ResolveObjectI,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<ResolveObject, ResolveObjectResponse>(
HttpType.Get,
"/resolve_object",
form,
options,
);
}
/**
* @summary Create a new community.
*/
@Security("bearerAuth")
@Post("/community")
@Tags("Community")
createCommunity(
@Body() form: CreateCommunity,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<CreateCommunity, CommunityResponse>(
HttpType.Post,
"/community",
form,
options,
);
}
/**
* @summary Get / fetch a community.
*/
@Security("bearerAuth")
@Security({})
@Get("/community")
@Tags("Community")
getCommunity(
@Queries() form: GetCommunityI = {},
@Inject() options?: RequestOptions,
) {
return this.#wrapper<GetCommunity, GetCommunityResponse>(
HttpType.Get,
"/community",
form,
options,
);
}
/**
* @summary Edit a community.
*/
@Security("bearerAuth")
@Put("/community")
@Tags("Community")
editCommunity(
@Body() form: EditCommunity,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<EditCommunity, CommunityResponse>(
HttpType.Put,
"/community",
form,
options,
);
}
/**
* @summary List communities, with various filters.
*/
@Security("bearerAuth")
@Security({})
@Get("/community/list")
@Tags("Community")
listCommunities(
@Queries() form: ListCommunitiesI = {},
@Inject() options?: RequestOptions,
) {
return this.#wrapper<ListCommunities, ListCommunitiesResponse>(
HttpType.Get,
"/community/list",
form,
options,
);
}
/**
* @summary Follow / subscribe to a community.
*/
@Security("bearerAuth")
@Post("/community/follow")
@Tags("Community")
followCommunity(
@Body() form: FollowCommunity,
@Inject() @Inject() options?: RequestOptions,
) {
return this.#wrapper<FollowCommunity, CommunityResponse>(
HttpType.Post,
"/community/follow",
form,
options,
);
}
/**
* @summary Get a community's pending follows count.
*/
@Security("bearerAuth")
@Get("/community/pending_follows/count")
@Tags("Community")
getCommunityPendingFollowsCount(
@Queries() form: GetCommunityPendingFollowsCountI,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<
GetCommunityPendingFollowsCount,
GetCommunityPendingFollowsCountResponse
>(HttpType.Get, "/community/pending_follows/count", form, options);
}
/**
* @summary Get a community's pending followers.
*/
@Security("bearerAuth")
@Get("/community/pending_follows/list")
@Tags("Community")
listCommunityPendingFollows(
@Queries() form: ListCommunityPendingFollowsI,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<
ListCommunityPendingFollows,
ListCommunityPendingFollowsResponse
>(HttpType.Get, "/community/pending_follows/list", form, options);
}
/**
* @summary Approve a community pending follow request.
*/
@Security("bearerAuth")
@Post("/community/pending_follows/approve")
@Tags("Community")
approveCommunityPendingFollow(
@Body() form: ApproveCommunityPendingFollower,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<ApproveCommunityPendingFollower, SuccessResponse>(
HttpType.Post,
"/community/pending_follows/approve",
form,
options,
);
}
/**
* @summary Block a community.
*/
@Security("bearerAuth")
@Post("/account/block/community")
@Tags("Account", "Community")
blockCommunity(
@Body() form: BlockCommunity,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<BlockCommunity, BlockCommunityResponse>(
HttpType.Post,
"/account/block/community",
form,
options,
);
}
/**
* @summary Delete a community.
*/
@Security("bearerAuth")
@Post("/community/delete")
@Tags("Community")
deleteCommunity(
@Body() form: DeleteCommunity,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<DeleteCommunity, CommunityResponse>(
HttpType.Post,
"/community/delete",
form,
options,
);
}
/**
* @summary Hide a community from public / "All" view. Admins only.
*/
@Security("bearerAuth")
@Put("/community/hide")
@Tags("Community", "Admin")
hideCommunity(
@Body() form: HideCommunity,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<HideCommunity, SuccessResponse>(
HttpType.Put,
"/community/hide",
form,
options,
);
}
/**
* @summary A moderator remove for a community.
*/
@Security("bearerAuth")
@Post("/community/remove")
@Tags("Community", "Moderator")
removeCommunity(
@Body() form: RemoveCommunity,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<RemoveCommunity, CommunityResponse>(
HttpType.Post,
"/community/remove",
form,
options,
);
}
/**
* @summary Transfer your community to an existing moderator.
*/
@Security("bearerAuth")
@Post("/community/transfer")
@Tags("Community", "Moderator")
transferCommunity(
@Body() form: TransferCommunity,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<TransferCommunity, GetCommunityResponse>(
HttpType.Post,
"/community/transfer",
form,
options,
);
}
/**
* @summary Ban a user from a community.
*/
@Security("bearerAuth")
@Post("/community/ban_user")
@Tags("Community", "Moderator")
banFromCommunity(
@Body() form: BanFromCommunity,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<BanFromCommunity, BanFromCommunityResponse>(
HttpType.Post,
"/community/ban_user",
form,
options,
);
}
/**
* @summary Add a moderator to your community.
*/
@Security("bearerAuth")
@Post("/community/mod")
@Tags("Community", "Moderator")
addModToCommunity(
@Body() form: AddModToCommunity,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<AddModToCommunity, AddModToCommunityResponse>(
HttpType.Post,
"/community/mod",
form,
options,
);
}
/**
* @summary Get a random community.
*/
@Security("bearerAuth")
@Security({})
@Get("/community/random")
@Tags("Community")
getRandomCommunity(
@Queries() form: GetRandomCommunityI,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<GetRandomCommunity, CommunityResponse>(
HttpType.Get,
"/community/random",
form,
options,
);
}
/**
* @summary Create a post.
*/
@Security("bearerAuth")
@Post("/post")
@Tags("Post")
createPost(@Body() form: CreatePost, @Inject() options?: RequestOptions) {
return this.#wrapper<CreatePost, PostResponse>(
HttpType.Post,
"/post",
form,
options,
);
}
/**
* @summary Get / fetch a post.
*/
@Security("bearerAuth")
@Security({})
@Get("/post")
@Tags("Post")
getPost(@Queries() form: GetPostI = {}, @Inject() options?: RequestOptions) {
return this.#wrapper<GetPost, GetPostResponse>(
HttpType.Get,
"/post",
form,
options,
);
}
/**
* @summary Edit a post.
*/
@Security("bearerAuth")
@Put("/post")
@Tags("Post")
editPost(@Body() form: EditPost, @Inject() options?: RequestOptions) {
return this.#wrapper<EditPost, PostResponse>(
HttpType.Put,
"/post",
form,
options,
);
}
/**
* @summary Delete a post.
*/
@Security("bearerAuth")
@Post("/post/delete")
@Tags("Post")
deletePost(@Body() form: DeletePost, @Inject() options?: RequestOptions) {
return this.#wrapper<DeletePost, PostResponse>(
HttpType.Post,
"/post/delete",
form,
options,
);
}
/**
* @summary A moderator remove for a post.
*/
@Security("bearerAuth")
@Post("/post/remove")
@Tags("Post", "Moderator")
removePost(@Body() form: RemovePost, @Inject() options?: RequestOptions) {
return this.#wrapper<RemovePost, PostResponse>(
HttpType.Post,
"/post/remove",
form,
options,
);
}
/**
* @summary Mark a post as read.
*/
@Security("bearerAuth")
@Post("/post/mark_as_read")
@Tags("Post")
markPostAsRead(
@Body() form: MarkPostAsRead,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<MarkPostAsRead, SuccessResponse>(
HttpType.Post,
"/post/mark_as_read",
form,
options,
);
}
/**
* @summary Mark multiple posts as read.
*/
@Security("bearerAuth")
@Post("/post/mark_as_read/many")
@Tags("Post")
markManyPostAsRead(
@Body() form: MarkManyPostsAsRead,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<MarkManyPostsAsRead, SuccessResponse>(
HttpType.Post,
"/post/mark_as_read/many",
form,
options,
);
}
/**
* @summary Hide a post from list views.
*/
@Security("bearerAuth")
@Post("/post/hide")
@Tags("Post")
hidePost(@Body() form: HidePost, @Inject() options?: RequestOptions) {
return this.#wrapper<HidePost, SuccessResponse>(
HttpType.Post,
"/post/hide",
form,
options,
);
}
/**
* @summary A moderator can lock a post ( IE disable new comments ).
*/
@Security("bearerAuth")
@Post("/post/lock")
@Tags("Post")
lockPost(@Body() form: LockPost, @Inject() options?: RequestOptions) {
return this.#wrapper<LockPost, PostResponse>(
HttpType.Post,
"/post/lock",
form,
options,
);
}
/**
* @summary A moderator can feature a community post ( IE stick it to the top of a community ).
*/
@Security("bearerAuth")
@Post("/post/feature")
@Tags("Post", "Moderator")
featurePost(@Body() form: FeaturePost, @Inject() options?: RequestOptions) {
return this.#wrapper<FeaturePost, PostResponse>(
HttpType.Post,
"/post/feature",
form,
options,
);
}
/**
* @summary Get / fetch posts, with various filters.
*/
@Security("bearerAuth")
@Security({})
@Get("/post/list")
@Tags("Post")
getPosts(
@Queries() form: GetPostsI = {},
@Inject() options?: RequestOptions,
) {
return this.#wrapper<GetPosts, GetPostsResponse>(
HttpType.Get,
"/post/list",
form,
options,
);
}
/**
* @summary Like / vote on a post.
*/
@Security("bearerAuth")
@Post("/post/like")
@Tags("Post")
likePost(@Body() form: CreatePostLike, @Inject() options?: RequestOptions) {
return this.#wrapper<CreatePostLike, PostResponse>(
HttpType.Post,
"/post/like",
form,
options,
);
}
/**
* @summary List a post's likes. Admin-only.
*/
@Security("bearerAuth")
@Get("/post/like/list")
@Tags("Post", "Admin")
listPostLikes(
@Queries() form: ListPostLikesI,
@Inject() options?: RequestOptions,