mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-26 22:31:12 +00:00
Adding admin purge to API.
This commit is contained in:
parent
e88a992d25
commit
51ef5ebceb
6 changed files with 163 additions and 0 deletions
33
src/http.ts
33
src/http.ts
|
@ -66,6 +66,11 @@ import {
|
|||
GetSiteConfig,
|
||||
GetSiteConfigResponse,
|
||||
GetSiteResponse,
|
||||
PurgeComment,
|
||||
PurgeCommunity,
|
||||
PurgeItemResponse,
|
||||
PurgePerson,
|
||||
PurgePost,
|
||||
ResolveObject,
|
||||
ResolveObjectResponse,
|
||||
SaveSiteConfig,
|
||||
|
@ -644,6 +649,34 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Post, '/admin/add', form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a person from the database.
|
||||
*/
|
||||
async purgePerson(form: PurgePerson): Promise<PurgeItemResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/purge/person', form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a community from the database.
|
||||
*/
|
||||
async purgeCommunity(form: PurgeCommunity): Promise<PurgeItemResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/purge/community', form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a post from the database.
|
||||
*/
|
||||
async purgePost(form: PurgePost): Promise<PurgeItemResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/purge/post', form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a comment from the database.
|
||||
*/
|
||||
async purgeComment(form: PurgeComment): Promise<PurgeItemResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/purge/comment', form);
|
||||
}
|
||||
|
||||
private buildFullUrl(endpoint: string): string {
|
||||
return `${this.apiUrl}${endpoint}`;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import {
|
||||
AdminPurgeCommentView,
|
||||
AdminPurgeCommunityView,
|
||||
AdminPurgePersonView,
|
||||
AdminPurgePostView,
|
||||
CommunityBlockView,
|
||||
CommunityFollowerView,
|
||||
CommunityModeratorView,
|
||||
|
@ -81,6 +85,10 @@ export interface GetModlogResponse {
|
|||
added_to_community: ModAddCommunityView[];
|
||||
transferred_to_community: ModTransferCommunityView[];
|
||||
added: ModAddView[];
|
||||
admin_purged_persons: AdminPurgePersonView[];
|
||||
admin_purged_communities: AdminPurgeCommunityView[];
|
||||
admin_purged_posts: AdminPurgePostView[];
|
||||
admin_purged_comments: AdminPurgeCommentView[];
|
||||
}
|
||||
|
||||
export interface CreateSite {
|
||||
|
@ -179,3 +187,33 @@ export interface ResolveObjectResponse {
|
|||
community?: CommunityView;
|
||||
person?: PersonViewSafe;
|
||||
}
|
||||
|
||||
export interface PurgePerson {
|
||||
person_id: number;
|
||||
remove_images: boolean;
|
||||
reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface PurgeCommunity {
|
||||
community_id: number;
|
||||
remove_images: boolean;
|
||||
reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface PurgePost {
|
||||
post_id: number;
|
||||
reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface PurgeComment {
|
||||
comment_id: number;
|
||||
reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface PurgeItemResponse {
|
||||
success: boolean;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,10 @@ export enum UserOperation {
|
|||
GetSiteMetadata,
|
||||
BlockCommunity,
|
||||
BlockPerson,
|
||||
PurgePerson,
|
||||
PurgeCommunity,
|
||||
PurgePost,
|
||||
PurgeComment,
|
||||
CreateCommentReport,
|
||||
ResolveCommentReport,
|
||||
ListCommentReports,
|
||||
|
|
|
@ -198,6 +198,36 @@ export interface ModAdd {
|
|||
when_: string;
|
||||
}
|
||||
|
||||
export interface AdminPurgePerson {
|
||||
id: number;
|
||||
admin_person_id: number;
|
||||
reason?: string;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface AdminPurgeCommunity {
|
||||
id: number;
|
||||
admin_person_id: number;
|
||||
reason?: string;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface AdminPurgePost {
|
||||
id: number;
|
||||
admin_person_id: number;
|
||||
community_id: number;
|
||||
reason?: string;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface AdminPurgeComment {
|
||||
id: number;
|
||||
admin_person_id: number;
|
||||
post_id: number;
|
||||
reason?: string;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface CommunitySafe {
|
||||
id: number;
|
||||
name: string;
|
||||
|
|
|
@ -26,6 +26,10 @@ import {
|
|||
PersonMention,
|
||||
PersonSafe,
|
||||
LocalUserSettings,
|
||||
AdminPurgeCommunity,
|
||||
AdminPurgePerson,
|
||||
AdminPurgePost,
|
||||
AdminPurgeComment,
|
||||
} from './source';
|
||||
|
||||
export interface PersonViewSafe {
|
||||
|
@ -187,6 +191,28 @@ export interface ModStickyPostView {
|
|||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface AdminPurgeCommunityView {
|
||||
admin_purge_community: AdminPurgeCommunity;
|
||||
admin: PersonSafe;
|
||||
}
|
||||
|
||||
export interface AdminPurgePersonView {
|
||||
admin_purge_person: AdminPurgePerson;
|
||||
admin: PersonSafe;
|
||||
}
|
||||
|
||||
export interface AdminPurgePostView {
|
||||
admin_purge_post: AdminPurgePost;
|
||||
admin: PersonSafe;
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface AdminPurgeCommentView {
|
||||
admin_purge_comment: AdminPurgeComment;
|
||||
admin: PersonSafe;
|
||||
post: Post;
|
||||
}
|
||||
|
||||
export interface CommunityFollowerView {
|
||||
community: CommunitySafe;
|
||||
follower: PersonSafe;
|
||||
|
|
|
@ -46,6 +46,10 @@ import {
|
|||
GetModlog,
|
||||
GetSite,
|
||||
GetSiteConfig,
|
||||
PurgeComment,
|
||||
PurgeCommunity,
|
||||
PurgePerson,
|
||||
PurgePost,
|
||||
ResolveObject,
|
||||
SaveSiteConfig,
|
||||
Search,
|
||||
|
@ -584,6 +588,34 @@ export class LemmyWebsocket {
|
|||
blockCommunity(form: BlockCommunity) {
|
||||
return wrapper(UserOperation.BlockCommunity, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a person from the database.
|
||||
*/
|
||||
purgePerson(form: PurgePerson) {
|
||||
return wrapper(UserOperation.PurgePerson, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a community from the database.
|
||||
*/
|
||||
purgeCommunity(form: PurgeCommunity) {
|
||||
return wrapper(UserOperation.PurgeCommunity, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a post from the database.
|
||||
*/
|
||||
purgePost(form: PurgePost) {
|
||||
return wrapper(UserOperation.PurgePost, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a comment from the database.
|
||||
*/
|
||||
purgeComment(form: PurgeComment) {
|
||||
return wrapper(UserOperation.PurgeComment, form);
|
||||
}
|
||||
}
|
||||
|
||||
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||
|
|
Loading…
Reference in a new issue