2021-12-06 19:44:10 +00:00
|
|
|
import fetch from "node-fetch";
|
2020-08-20 02:25:21 +00:00
|
|
|
import {
|
2021-09-28 10:38:49 +00:00
|
|
|
CommentReportResponse,
|
2020-12-20 17:33:14 +00:00
|
|
|
CommentResponse,
|
|
|
|
CreateComment,
|
|
|
|
CreateCommentLike,
|
2021-09-28 10:38:49 +00:00
|
|
|
CreateCommentReport,
|
2020-12-20 17:33:14 +00:00
|
|
|
DeleteComment,
|
|
|
|
EditComment,
|
|
|
|
GetComments,
|
|
|
|
GetCommentsResponse,
|
2021-09-28 10:38:49 +00:00
|
|
|
ListCommentReports,
|
|
|
|
ListCommentReportsResponse,
|
2020-12-20 17:33:14 +00:00
|
|
|
RemoveComment,
|
2021-09-28 10:38:49 +00:00
|
|
|
ResolveCommentReport,
|
2020-12-20 17:33:14 +00:00
|
|
|
SaveComment,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/comment";
|
2020-12-20 17:33:14 +00:00
|
|
|
import {
|
|
|
|
AddModToCommunity,
|
|
|
|
AddModToCommunityResponse,
|
|
|
|
BanFromCommunity,
|
|
|
|
BanFromCommunityResponse,
|
2021-08-20 00:49:15 +00:00
|
|
|
BlockCommunity,
|
|
|
|
BlockCommunityResponse,
|
2020-12-20 17:33:14 +00:00
|
|
|
CommunityResponse,
|
|
|
|
CreateCommunity,
|
|
|
|
DeleteCommunity,
|
|
|
|
EditCommunity,
|
|
|
|
FollowCommunity,
|
|
|
|
GetCommunity,
|
|
|
|
GetCommunityResponse,
|
|
|
|
ListCommunities,
|
|
|
|
ListCommunitiesResponse,
|
|
|
|
RemoveCommunity,
|
|
|
|
TransferCommunity,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/community";
|
2022-11-28 03:25:00 +00:00
|
|
|
import {
|
|
|
|
CreateCustomEmoji,
|
|
|
|
CustomEmojiResponse,
|
|
|
|
DeleteCustomEmoji,
|
|
|
|
DeleteCustomEmojiResponse,
|
|
|
|
EditCustomEmoji,
|
|
|
|
} from "./interfaces/api/custom_emoji";
|
2021-12-06 19:44:10 +00:00
|
|
|
import {
|
|
|
|
AddAdmin,
|
|
|
|
AddAdminResponse,
|
2022-01-06 16:19:36 +00:00
|
|
|
BannedPersonsResponse,
|
2021-12-06 19:44:10 +00:00
|
|
|
BanPerson,
|
|
|
|
BanPersonResponse,
|
|
|
|
BlockPerson,
|
|
|
|
BlockPersonResponse,
|
|
|
|
ChangePassword,
|
|
|
|
CreatePrivateMessage,
|
2022-09-28 02:57:11 +00:00
|
|
|
CreatePrivateMessageReport,
|
2021-12-06 19:44:10 +00:00
|
|
|
DeleteAccount,
|
2021-12-30 15:27:05 +00:00
|
|
|
DeleteAccountResponse,
|
2021-12-06 19:44:10 +00:00
|
|
|
DeletePrivateMessage,
|
|
|
|
EditPrivateMessage,
|
2022-01-06 16:19:36 +00:00
|
|
|
GetBannedPersons,
|
2021-12-06 19:44:10 +00:00
|
|
|
GetCaptchaResponse,
|
|
|
|
GetPersonDetails,
|
|
|
|
GetPersonDetailsResponse,
|
|
|
|
GetPersonMentions,
|
|
|
|
GetPersonMentionsResponse,
|
|
|
|
GetPrivateMessages,
|
|
|
|
GetReplies,
|
|
|
|
GetRepliesResponse,
|
|
|
|
GetReportCount,
|
|
|
|
GetReportCountResponse,
|
|
|
|
GetUnreadCount,
|
|
|
|
GetUnreadCountResponse,
|
2022-09-28 02:57:11 +00:00
|
|
|
ListPrivateMessageReports,
|
|
|
|
ListPrivateMessageReportsResponse,
|
2021-12-06 19:44:10 +00:00
|
|
|
Login,
|
|
|
|
LoginResponse,
|
|
|
|
MarkAllAsRead,
|
2022-07-30 03:33:06 +00:00
|
|
|
MarkCommentReplyAsRead,
|
2021-12-06 19:44:10 +00:00
|
|
|
MarkPersonMentionAsRead,
|
|
|
|
MarkPrivateMessageAsRead,
|
|
|
|
PasswordChange,
|
|
|
|
PasswordReset,
|
|
|
|
PasswordResetResponse,
|
|
|
|
PersonMentionResponse,
|
2022-09-28 02:57:11 +00:00
|
|
|
PrivateMessageReportResponse,
|
2021-12-06 19:44:10 +00:00
|
|
|
PrivateMessageResponse,
|
|
|
|
PrivateMessagesResponse,
|
|
|
|
Register,
|
2022-09-28 02:57:11 +00:00
|
|
|
ResolvePrivateMessageReport,
|
2021-12-06 19:44:10 +00:00
|
|
|
SaveUserSettings,
|
2021-12-30 15:27:05 +00:00
|
|
|
VerifyEmail,
|
|
|
|
VerifyEmailResponse,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/person";
|
2020-12-20 17:33:14 +00:00
|
|
|
import {
|
|
|
|
CreatePost,
|
|
|
|
CreatePostLike,
|
2021-12-06 19:44:10 +00:00
|
|
|
CreatePostReport,
|
2020-12-20 17:33:14 +00:00
|
|
|
DeletePost,
|
|
|
|
EditPost,
|
2022-12-11 15:20:01 +00:00
|
|
|
FeaturePost,
|
2020-12-20 17:33:14 +00:00
|
|
|
GetPost,
|
|
|
|
GetPostResponse,
|
|
|
|
GetPosts,
|
|
|
|
GetPostsResponse,
|
2021-08-19 15:14:39 +00:00
|
|
|
GetSiteMetadata,
|
|
|
|
GetSiteMetadataResponse,
|
2021-12-06 19:44:10 +00:00
|
|
|
ListPostReports,
|
|
|
|
ListPostReportsResponse,
|
2020-12-20 17:33:14 +00:00
|
|
|
LockPost,
|
2022-05-22 19:46:20 +00:00
|
|
|
MarkPostAsRead,
|
2021-09-28 10:38:49 +00:00
|
|
|
PostReportResponse,
|
2020-12-20 17:33:14 +00:00
|
|
|
PostResponse,
|
|
|
|
RemovePost,
|
2021-12-06 19:44:10 +00:00
|
|
|
ResolvePostReport,
|
2020-12-20 17:33:14 +00:00
|
|
|
SavePost,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/post";
|
2020-12-20 17:33:14 +00:00
|
|
|
import {
|
2021-12-30 15:27:05 +00:00
|
|
|
ApproveRegistrationApplication,
|
2020-12-20 17:33:14 +00:00
|
|
|
CreateSite,
|
|
|
|
EditSite,
|
|
|
|
GetModlog,
|
|
|
|
GetModlogResponse,
|
|
|
|
GetSite,
|
|
|
|
GetSiteResponse,
|
2021-12-30 15:27:05 +00:00
|
|
|
GetUnreadRegistrationApplicationCount,
|
|
|
|
GetUnreadRegistrationApplicationCountResponse,
|
2022-03-01 16:54:51 +00:00
|
|
|
LeaveAdmin,
|
2021-12-30 15:27:05 +00:00
|
|
|
ListRegistrationApplications,
|
|
|
|
ListRegistrationApplicationsResponse,
|
2022-06-23 18:50:20 +00:00
|
|
|
PurgeComment,
|
|
|
|
PurgeCommunity,
|
|
|
|
PurgeItemResponse,
|
|
|
|
PurgePerson,
|
|
|
|
PurgePost,
|
2021-12-30 15:27:05 +00:00
|
|
|
RegistrationApplicationResponse,
|
2021-08-23 20:15:24 +00:00
|
|
|
ResolveObject,
|
|
|
|
ResolveObjectResponse,
|
2020-12-20 17:33:14 +00:00
|
|
|
Search,
|
2020-08-20 02:25:21 +00:00
|
|
|
SearchResponse,
|
2020-12-20 17:33:14 +00:00
|
|
|
SiteResponse,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/site";
|
|
|
|
import { VERSION } from "./interfaces/others";
|
2021-03-29 14:29:27 +00:00
|
|
|
|
2020-08-20 02:25:21 +00:00
|
|
|
enum HttpType {
|
2021-12-06 19:44:10 +00:00
|
|
|
Get = "GET",
|
|
|
|
Post = "POST",
|
|
|
|
Put = "PUT",
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Helps build lemmy HTTP requests.
|
|
|
|
*/
|
2020-08-20 02:25:21 +00:00
|
|
|
export class LemmyHttp {
|
2021-03-29 14:29:27 +00:00
|
|
|
private apiUrl: string;
|
2020-11-12 19:42:31 +00:00
|
|
|
private headers: { [key: string]: string } = {};
|
2020-08-20 02:25:21 +00:00
|
|
|
|
2021-01-24 17:37:04 +00:00
|
|
|
/**
|
2021-08-23 01:01:40 +00:00
|
|
|
* Generates a new instance of LemmyHttp.
|
2021-03-29 14:29:27 +00:00
|
|
|
* @param baseUrl the base url, without the vX version: https://lemmy.ml -> goes to https://lemmy.ml/api/vX
|
2021-08-23 01:01:40 +00:00
|
|
|
* @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` .
|
2021-01-24 17:37:04 +00:00
|
|
|
*/
|
2020-11-12 19:42:31 +00:00
|
|
|
constructor(baseUrl: string, headers?: { [key: string]: string }) {
|
2021-03-29 14:29:27 +00:00
|
|
|
this.apiUrl = `${baseUrl}/api/${VERSION}`;
|
2020-11-12 19:42:31 +00:00
|
|
|
|
|
|
|
if (headers) {
|
|
|
|
this.headers = headers;
|
|
|
|
}
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Gets the site, and your user data.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /site`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getSite(form: GetSite) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetSite, GetSiteResponse>(HttpType.Get, "/site", form);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create your site.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /site`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async createSite(form: CreateSite) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<CreateSite, SiteResponse>(HttpType.Post, "/site", form);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit your site.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /site`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async editSite(form: EditSite) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<EditSite, SiteResponse>(HttpType.Put, "/site", form);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
2022-03-01 16:54:51 +00:00
|
|
|
* Leave the Site admins.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/leave_admin`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async leaveAdmin(form: LeaveAdmin) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<LeaveAdmin, GetSiteResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/user/leave_admin",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get the modlog.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /modlog`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getModlog(form: GetModlog) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetModlog, GetModlogResponse>(
|
|
|
|
HttpType.Get,
|
|
|
|
"/modlog",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Search lemmy.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /search`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async search(form: Search) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<Search, SearchResponse>(HttpType.Get, "/search", form);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 20:15:24 +00:00
|
|
|
/**
|
|
|
|
* Fetch a non-local / federated object.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /resolve_object`
|
2021-08-23 20:15:24 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async resolveObject(form: ResolveObject) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<ResolveObject, ResolveObjectResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/resolve_object",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-08-23 20:15:24 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create a new community.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /community`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async createCommunity(form: CreateCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<CreateCommunity, CommunityResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/community",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch a community.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /community`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getCommunity(form: GetCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetCommunity, GetCommunityResponse>(
|
|
|
|
HttpType.Get,
|
|
|
|
"/community",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit a community.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /community`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async editCommunity(form: EditCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<EditCommunity, CommunityResponse>(
|
|
|
|
HttpType.Put,
|
|
|
|
"/community",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* List communities, with various filters.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /community/list`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async listCommunities(form: ListCommunities) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<ListCommunities, ListCommunitiesResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/community/list",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Follow / subscribe to a community.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /community/follow`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async followCommunity(form: FollowCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<FollowCommunity, CommunityResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/community/follow",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Block a community.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /community/block`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async blockCommunity(form: BlockCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<BlockCommunity, BlockCommunityResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/community/block",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-08-20 00:49:15 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete a community.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /community/delete`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async deleteCommunity(form: DeleteCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<DeleteCommunity, CommunityResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/community/delete",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A moderator remove for a community.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /community/remove`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async removeCommunity(form: RemoveCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<RemoveCommunity, CommunityResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/community/remove",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Transfer your community to an existing moderator.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /community/transfer`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async transferCommunity(form: TransferCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<TransferCommunity, GetCommunityResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/community/transfer",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Ban a user from a community.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /community/ban_user`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async banFromCommunity(form: BanFromCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<BanFromCommunity, BanFromCommunityResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/community/ban_user",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Add a moderator to your community.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /community/mod`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async addModToCommunity(form: AddModToCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<AddModToCommunity, AddModToCommunityResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/community/mod",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create a post.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /post`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async createPost(form: CreatePost) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<CreatePost, PostResponse>(HttpType.Post, "/post", form);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch a post.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /post`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getPost(form: GetPost) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetPost, GetPostResponse>(HttpType.Get, "/post", form);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit a post.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /post`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async editPost(form: EditPost) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<EditPost, PostResponse>(HttpType.Put, "/post", form);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete a post.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /post/delete`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async deletePost(form: DeletePost) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<DeletePost, PostResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/post/delete",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A moderator remove for a post.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /post/remove`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async removePost(form: RemovePost) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<RemovePost, PostResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/post/remove",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2022-05-22 19:46:20 +00:00
|
|
|
/**
|
|
|
|
* Mark a post as read.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:46:20 +00:00
|
|
|
* `HTTP.POST /post/mark_as_read`
|
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async markPostAsRead(form: MarkPostAsRead) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<MarkPostAsRead, PostResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/post/mark_as_read",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2022-05-22 19:46:20 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A moderator can lock a post ( IE disable new comments ).
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /post/lock`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async lockPost(form: LockPost) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<LockPost, PostResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/post/lock",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
2022-12-11 15:20:01 +00:00
|
|
|
* A moderator can feature a community post ( IE stick it to the top of a community ).
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-12-11 15:20:01 +00:00
|
|
|
* `HTTP.POST /post/feature`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-12-11 15:20:01 +00:00
|
|
|
async featurePost(form: FeaturePost) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<FeaturePost, PostResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/post/feature",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch posts, with various filters.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /post/list`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getPosts(form: GetPosts) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetPosts, GetPostsResponse>(
|
|
|
|
HttpType.Get,
|
|
|
|
"/post/list",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Like / vote on a post.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /post/like`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async likePost(form: CreatePostLike) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<CreatePostLike, PostResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/post/like",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Save a post.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /post/save`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async savePost(form: SavePost) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<SavePost, PostResponse>(
|
|
|
|
HttpType.Put,
|
|
|
|
"/post/save",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 10:38:49 +00:00
|
|
|
/**
|
|
|
|
* Report a post.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /post/report`
|
2021-09-28 10:38:49 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async createPostReport(form: CreatePostReport) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<CreatePostReport, PostReportResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/post/report",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-09-28 10:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resolve a post report. Only a mod can do this.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /post/report/resolve`
|
2021-09-28 10:38:49 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async resolvePostReport(form: ResolvePostReport) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<ResolvePostReport, PostReportResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Put,
|
|
|
|
"/post/report/resolve",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-09-28 10:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List post reports.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /post/report/list`
|
2021-09-28 10:38:49 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async listPostReports(form: ListPostReports) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<ListPostReports, ListPostReportsResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/post/report/list",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-09-28 10:38:49 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Fetch metadata for any given site.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /post/site_metadata`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getSiteMetadata(form: GetSiteMetadata) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetSiteMetadata, GetSiteMetadataResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/post/site_metadata",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-08-19 15:14:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create a comment.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /comment`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async createComment(form: CreateComment) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<CreateComment, CommentResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/comment",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit a comment.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /comment`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async editComment(form: EditComment) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<EditComment, CommentResponse>(
|
|
|
|
HttpType.Put,
|
|
|
|
"/comment",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete a comment.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /comment/delete`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async deleteComment(form: DeleteComment) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<DeleteComment, CommentResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/comment/delete",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A moderator remove for a comment.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /comment/remove`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async removeComment(form: RemoveComment) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<RemoveComment, CommentResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/comment/remove",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Mark a comment as read.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /comment/mark_as_read`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-07-30 03:33:06 +00:00
|
|
|
async markCommentReplyAsRead(form: MarkCommentReplyAsRead) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<MarkCommentReplyAsRead, CommentResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/comment/mark_as_read",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Like / vote on a comment.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /comment/like`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async likeComment(form: CreateCommentLike) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<CreateCommentLike, CommentResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/comment/like",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Save a comment.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /comment/save`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async saveComment(form: SaveComment) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<SaveComment, CommentResponse>(
|
|
|
|
HttpType.Put,
|
|
|
|
"/comment/save",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch comments.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /comment/list`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getComments(form: GetComments) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetComments, GetCommentsResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/comment/list",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 10:38:49 +00:00
|
|
|
/**
|
|
|
|
* Report a comment.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /comment/report`
|
2021-09-28 10:38:49 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async createCommentReport(form: CreateCommentReport) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<CreateCommentReport, CommentReportResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/comment/report",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-09-28 10:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resolve a comment report. Only a mod can do this.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /comment/report/resolve`
|
2021-09-28 10:38:49 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async resolveCommentReport(form: ResolveCommentReport) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<ResolveCommentReport, CommentReportResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Put,
|
|
|
|
"/comment/report/resolve",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-09-28 10:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List comment reports.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /comment/report/list`
|
2021-09-28 10:38:49 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async listCommentReports(form: ListCommentReports) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<ListCommentReports, ListCommentReportsResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/comment/report/list",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-09-28 10:38:49 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch private messages.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /private_message/list`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getPrivateMessages(form: GetPrivateMessages) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetPrivateMessages, PrivateMessagesResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/private_message/list",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create a private message.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /private_message`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async createPrivateMessage(form: CreatePrivateMessage) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<CreatePrivateMessage, PrivateMessageResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/private_message",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit a private message.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /private_message`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async editPrivateMessage(form: EditPrivateMessage) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<EditPrivateMessage, PrivateMessageResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Put,
|
|
|
|
"/private_message",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete a private message.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /private_message/delete`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async deletePrivateMessage(form: DeletePrivateMessage) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<DeletePrivateMessage, PrivateMessageResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/private_message/delete",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Mark a private message as read.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /private_message/mark_as_read`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async markPrivateMessageAsRead(form: MarkPrivateMessageAsRead) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<MarkPrivateMessageAsRead, PrivateMessageResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/private_message/mark_as_read",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2022-09-28 02:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a report for a private message.
|
|
|
|
*
|
|
|
|
* `HTTP.POST /private_message/report`
|
|
|
|
*/
|
|
|
|
async createPrivateMessageReport(form: CreatePrivateMessageReport) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<
|
|
|
|
CreatePrivateMessageReport,
|
2022-09-28 02:57:11 +00:00
|
|
|
PrivateMessageReportResponse
|
2023-01-04 16:29:06 +00:00
|
|
|
>(HttpType.Post, "/private_message/report", form);
|
2022-09-28 02:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resolve a report for a private message.
|
|
|
|
*
|
|
|
|
* `HTTP.PUT /private_message/report/resolve`
|
|
|
|
*/
|
|
|
|
async resolvePrivateMessageReport(form: ResolvePrivateMessageReport) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<
|
|
|
|
ResolvePrivateMessageReport,
|
2022-09-28 02:57:11 +00:00
|
|
|
PrivateMessageReportResponse
|
2023-01-04 16:29:06 +00:00
|
|
|
>(HttpType.Put, "/private_message/report/resolve", form);
|
2022-09-28 02:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List private message reports.
|
|
|
|
*
|
|
|
|
* `HTTP.GET /private_message/report/list`
|
|
|
|
*/
|
|
|
|
async listPrivateMessageReports(form: ListPrivateMessageReports) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<
|
|
|
|
ListPrivateMessageReports,
|
2022-09-28 02:57:11 +00:00
|
|
|
ListPrivateMessageReportsResponse
|
2023-01-04 16:29:06 +00:00
|
|
|
>(HttpType.Get, "/private_message/report/list", form);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Register a new user.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/register`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async register(form: Register) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<Register, LoginResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/user/register",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Log into lemmy.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/login`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async login(form: Login) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<Login, LoginResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/user/login",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get the details for a person.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /user`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getPersonDetails(form: GetPersonDetails) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetPersonDetails, GetPersonDetailsResponse>(
|
|
|
|
HttpType.Get,
|
|
|
|
"/user",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get mentions for your user.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /user/mention`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getPersonMentions(form: GetPersonMentions) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetPersonMentions, GetPersonMentionsResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/user/mention",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Mark a person mention as read.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/mention/mark_as_read`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async markPersonMentionAsRead(form: MarkPersonMentionAsRead) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<MarkPersonMentionAsRead, PersonMentionResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/user/mention/mark_as_read",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get comment replies.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /user/replies`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getReplies(form: GetReplies) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetReplies, GetRepliesResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/user/replies",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Ban a person from your site.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/ban`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async banPerson(form: BanPerson) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<BanPerson, BanPersonResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/user/ban",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 16:19:36 +00:00
|
|
|
/**
|
|
|
|
* Get a list of banned users
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /user/banned`
|
2022-01-06 16:19:36 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getBannedPersons(form: GetBannedPersons) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetBannedPersons, BannedPersonsResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/user/banned",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2022-01-06 16:19:36 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Block a person.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/block`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async blockPerson(form: BlockPerson) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<BlockPerson, BlockPersonResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/user/block",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-08-20 00:49:15 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Fetch a Captcha.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /user/get_captcha`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getCaptcha() {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<any, GetCaptchaResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/user/get_captcha",
|
2023-01-04 16:29:06 +00:00
|
|
|
{}
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete your account.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/delete_account`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async deleteAccount(form: DeleteAccount) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<DeleteAccount, DeleteAccountResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/user/delete_account",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Reset your password.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/password_reset`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async passwordReset(form: PasswordReset) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<PasswordReset, PasswordResetResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/user/password_reset",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Change your password from an email / token based reset.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/password_change`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async passwordChange(form: PasswordChange) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<PasswordChange, LoginResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/user/password_change",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Mark all replies as read.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/mark_all_as_read`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async markAllAsRead(form: MarkAllAsRead) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<MarkAllAsRead, GetRepliesResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/user/mark_all_as_read",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Save your user settings.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /user/save_user_settings`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async saveUserSettings(form: SaveUserSettings) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<SaveUserSettings, LoginResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Put,
|
|
|
|
"/user/save_user_settings",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Change your user password.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /user/change_password`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async changePassword(form: ChangePassword) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<ChangePassword, LoginResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Put,
|
|
|
|
"/user/change_password",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-04-01 21:35:37 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 10:38:49 +00:00
|
|
|
/**
|
|
|
|
* Get counts for your reports
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /user/report_count`
|
2021-09-28 10:38:49 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getReportCount(form: GetReportCount) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetReportCount, GetReportCountResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/user/report_count",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-09-28 10:38:49 +00:00
|
|
|
}
|
|
|
|
|
2021-10-17 17:42:40 +00:00
|
|
|
/**
|
|
|
|
* Get your unread counts
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /user/unread_count`
|
2021-10-17 17:42:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async getUnreadCount(form: GetUnreadCount) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<GetUnreadCount, GetUnreadCountResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Get,
|
|
|
|
"/user/unread_count",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-10-17 17:42:40 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 15:27:05 +00:00
|
|
|
/**
|
|
|
|
* Verify your email
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /user/verify_email`
|
2021-12-30 15:27:05 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async verifyEmail(form: VerifyEmail) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<VerifyEmail, VerifyEmailResponse>(
|
2022-06-21 21:42:09 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/user/verify_email",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-21 21:42:09 +00:00
|
|
|
);
|
2021-12-30 15:27:05 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Add an admin to your site.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.POST /admin/add`
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async addAdmin(form: AddAdmin) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<AddAdmin, AddAdminResponse>(
|
|
|
|
HttpType.Post,
|
|
|
|
"/admin/add",
|
|
|
|
form
|
|
|
|
);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 15:27:05 +00:00
|
|
|
/**
|
|
|
|
* Get the unread registration applications count.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /admin/registration_application/count`
|
2021-12-30 15:27:05 +00:00
|
|
|
*/
|
|
|
|
async getUnreadRegistrationApplicationCount(
|
|
|
|
form: GetUnreadRegistrationApplicationCount
|
2022-06-21 21:42:09 +00:00
|
|
|
) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<
|
|
|
|
GetUnreadRegistrationApplicationCount,
|
2022-06-21 21:42:09 +00:00
|
|
|
GetUnreadRegistrationApplicationCountResponse
|
2023-01-04 16:29:06 +00:00
|
|
|
>(HttpType.Get, "/admin/registration_application/count", form);
|
2021-12-30 15:27:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-05-22 19:45:53 +00:00
|
|
|
* List the registration applications.
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.GET /admin/registration_application/list`
|
2021-12-30 15:27:05 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async listRegistrationApplications(form: ListRegistrationApplications) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<
|
|
|
|
ListRegistrationApplications,
|
2022-06-21 21:42:09 +00:00
|
|
|
ListRegistrationApplicationsResponse
|
2023-01-04 16:29:06 +00:00
|
|
|
>(HttpType.Get, "/admin/registration_application/list", form);
|
2021-12-30 15:27:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Approve a registration application
|
2022-06-21 21:42:09 +00:00
|
|
|
*
|
2022-05-22 19:45:53 +00:00
|
|
|
* `HTTP.PUT /admin/registration_application/approve`
|
2021-12-30 15:27:05 +00:00
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
async approveRegistrationApplication(form: ApproveRegistrationApplication) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<
|
|
|
|
ApproveRegistrationApplication,
|
2022-06-21 21:42:09 +00:00
|
|
|
RegistrationApplicationResponse
|
2023-01-04 16:29:06 +00:00
|
|
|
>(HttpType.Put, "/admin/registration_application/approve", form);
|
2021-12-30 15:27:05 +00:00
|
|
|
}
|
|
|
|
|
2022-06-23 18:50:20 +00:00
|
|
|
/**
|
|
|
|
* Purge / Delete a person from the database.
|
|
|
|
*
|
|
|
|
* `HTTP.POST /admin/purge/person`
|
|
|
|
*/
|
|
|
|
async purgePerson(form: PurgePerson) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<PurgePerson, PurgeItemResponse>(
|
2022-06-23 18:50:20 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/admin/purge/person",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-23 18:50:20 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Purge / Delete a community from the database.
|
|
|
|
*
|
|
|
|
* `HTTP.POST /admin/purge/community`
|
|
|
|
*/
|
|
|
|
async purgeCommunity(form: PurgeCommunity) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<PurgeCommunity, PurgeItemResponse>(
|
2022-06-23 18:50:20 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/admin/purge/community",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-23 18:50:20 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Purge / Delete a post from the database.
|
|
|
|
*
|
|
|
|
* `HTTP.POST /admin/purge/post`
|
|
|
|
*/
|
|
|
|
async purgePost(form: PurgePost) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<PurgePost, PurgeItemResponse>(
|
2022-06-23 18:50:20 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/admin/purge/post",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-23 18:50:20 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Purge / Delete a comment from the database.
|
|
|
|
*
|
|
|
|
* `HTTP.POST /admin/purge/comment`
|
|
|
|
*/
|
|
|
|
async purgeComment(form: PurgeComment) {
|
2023-01-04 16:29:06 +00:00
|
|
|
return this.wrapper<PurgeComment, PurgeItemResponse>(
|
2022-06-23 18:50:20 +00:00
|
|
|
HttpType.Post,
|
|
|
|
"/admin/purge/comment",
|
2023-01-04 16:29:06 +00:00
|
|
|
form
|
2022-06-23 18:50:20 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-11-28 03:25:00 +00:00
|
|
|
/**
|
|
|
|
* Create a new custom emoji
|
|
|
|
*
|
|
|
|
* `HTTP.POST /custom_emoji`
|
|
|
|
*/
|
|
|
|
async createCustomEmoji(form: CreateCustomEmoji) {
|
|
|
|
return this.wrapper(
|
|
|
|
HttpType.Post,
|
|
|
|
"/custom_emoji",
|
|
|
|
form,
|
|
|
|
CustomEmojiResponse
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit an existing custom emoji
|
|
|
|
*
|
|
|
|
* `HTTP.PUT /custom_emoji`
|
|
|
|
*/
|
|
|
|
async editCustomEmoji(form: EditCustomEmoji) {
|
|
|
|
return this.wrapper(
|
|
|
|
HttpType.Put,
|
|
|
|
"/custom_emoji",
|
|
|
|
form,
|
|
|
|
CustomEmojiResponse
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a custom emoji
|
|
|
|
*
|
|
|
|
* `HTTP.Post /custom_emoji/delete`
|
|
|
|
*/
|
|
|
|
async deleteCustomEmoji(form: DeleteCustomEmoji) {
|
|
|
|
return this.wrapper(
|
|
|
|
HttpType.Post,
|
|
|
|
"/custom_emoji/delete",
|
|
|
|
form,
|
|
|
|
DeleteCustomEmojiResponse
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-20 02:25:21 +00:00
|
|
|
private buildFullUrl(endpoint: string): string {
|
2021-03-29 14:29:27 +00:00
|
|
|
return `${this.apiUrl}${endpoint}`;
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
|
2023-01-04 16:29:06 +00:00
|
|
|
private async wrapper<BodyType extends object, ResponseType>(
|
2020-08-20 02:25:21 +00:00
|
|
|
type_: HttpType,
|
|
|
|
endpoint: string,
|
2023-01-04 16:29:06 +00:00
|
|
|
form: BodyType
|
2020-12-20 19:21:26 +00:00
|
|
|
): Promise<ResponseType> {
|
2020-08-20 02:25:21 +00:00
|
|
|
if (type_ == HttpType.Get) {
|
2020-08-20 03:51:57 +00:00
|
|
|
let getUrl = `${this.buildFullUrl(endpoint)}?${encodeGetParams(form)}`;
|
2022-07-30 03:33:06 +00:00
|
|
|
return fetch(getUrl, {
|
|
|
|
method: "GET",
|
|
|
|
headers: this.headers,
|
2023-01-04 16:29:06 +00:00
|
|
|
}).then(d => d.json() as Promise<ResponseType>);
|
2020-08-20 02:25:21 +00:00
|
|
|
} else {
|
|
|
|
return fetch(this.buildFullUrl(endpoint), {
|
|
|
|
method: type_,
|
|
|
|
headers: {
|
2021-12-06 19:44:10 +00:00
|
|
|
"Content-Type": "application/json",
|
2020-11-12 19:42:31 +00:00
|
|
|
...this.headers,
|
2020-08-20 02:25:21 +00:00
|
|
|
},
|
2023-01-04 16:29:06 +00:00
|
|
|
body: JSON.stringify(form),
|
|
|
|
}).then(d => d.json() as Promise<ResponseType>);
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 16:29:06 +00:00
|
|
|
function encodeGetParams<BodyType extends object>(p: BodyType): string {
|
|
|
|
return Object.entries(p)
|
|
|
|
.filter(kv => !!kv[1])
|
2022-07-30 03:33:06 +00:00
|
|
|
.map(kv => kv.map(encodeURIComponent).join("="))
|
|
|
|
.join("&");
|
2020-08-20 02:25:21 +00:00
|
|
|
}
|