mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-30 08:11:11 +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,
|
GetSiteConfig,
|
||||||
GetSiteConfigResponse,
|
GetSiteConfigResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
|
PurgeComment,
|
||||||
|
PurgeCommunity,
|
||||||
|
PurgeItemResponse,
|
||||||
|
PurgePerson,
|
||||||
|
PurgePost,
|
||||||
ResolveObject,
|
ResolveObject,
|
||||||
ResolveObjectResponse,
|
ResolveObjectResponse,
|
||||||
SaveSiteConfig,
|
SaveSiteConfig,
|
||||||
|
@ -644,6 +649,34 @@ export class LemmyHttp {
|
||||||
return this.wrapper(HttpType.Post, '/admin/add', form);
|
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 {
|
private buildFullUrl(endpoint: string): string {
|
||||||
return `${this.apiUrl}${endpoint}`;
|
return `${this.apiUrl}${endpoint}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
import {
|
import {
|
||||||
|
AdminPurgeCommentView,
|
||||||
|
AdminPurgeCommunityView,
|
||||||
|
AdminPurgePersonView,
|
||||||
|
AdminPurgePostView,
|
||||||
CommunityBlockView,
|
CommunityBlockView,
|
||||||
CommunityFollowerView,
|
CommunityFollowerView,
|
||||||
CommunityModeratorView,
|
CommunityModeratorView,
|
||||||
|
@ -81,6 +85,10 @@ export interface GetModlogResponse {
|
||||||
added_to_community: ModAddCommunityView[];
|
added_to_community: ModAddCommunityView[];
|
||||||
transferred_to_community: ModTransferCommunityView[];
|
transferred_to_community: ModTransferCommunityView[];
|
||||||
added: ModAddView[];
|
added: ModAddView[];
|
||||||
|
admin_purged_persons: AdminPurgePersonView[];
|
||||||
|
admin_purged_communities: AdminPurgeCommunityView[];
|
||||||
|
admin_purged_posts: AdminPurgePostView[];
|
||||||
|
admin_purged_comments: AdminPurgeCommentView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateSite {
|
export interface CreateSite {
|
||||||
|
@ -179,3 +187,33 @@ export interface ResolveObjectResponse {
|
||||||
community?: CommunityView;
|
community?: CommunityView;
|
||||||
person?: PersonViewSafe;
|
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,
|
GetSiteMetadata,
|
||||||
BlockCommunity,
|
BlockCommunity,
|
||||||
BlockPerson,
|
BlockPerson,
|
||||||
|
PurgePerson,
|
||||||
|
PurgeCommunity,
|
||||||
|
PurgePost,
|
||||||
|
PurgeComment,
|
||||||
CreateCommentReport,
|
CreateCommentReport,
|
||||||
ResolveCommentReport,
|
ResolveCommentReport,
|
||||||
ListCommentReports,
|
ListCommentReports,
|
||||||
|
|
|
@ -198,6 +198,36 @@ export interface ModAdd {
|
||||||
when_: string;
|
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 {
|
export interface CommunitySafe {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -26,6 +26,10 @@ import {
|
||||||
PersonMention,
|
PersonMention,
|
||||||
PersonSafe,
|
PersonSafe,
|
||||||
LocalUserSettings,
|
LocalUserSettings,
|
||||||
|
AdminPurgeCommunity,
|
||||||
|
AdminPurgePerson,
|
||||||
|
AdminPurgePost,
|
||||||
|
AdminPurgeComment,
|
||||||
} from './source';
|
} from './source';
|
||||||
|
|
||||||
export interface PersonViewSafe {
|
export interface PersonViewSafe {
|
||||||
|
@ -187,6 +191,28 @@ export interface ModStickyPostView {
|
||||||
community: CommunitySafe;
|
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 {
|
export interface CommunityFollowerView {
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
follower: PersonSafe;
|
follower: PersonSafe;
|
||||||
|
|
|
@ -46,6 +46,10 @@ import {
|
||||||
GetModlog,
|
GetModlog,
|
||||||
GetSite,
|
GetSite,
|
||||||
GetSiteConfig,
|
GetSiteConfig,
|
||||||
|
PurgeComment,
|
||||||
|
PurgeCommunity,
|
||||||
|
PurgePerson,
|
||||||
|
PurgePost,
|
||||||
ResolveObject,
|
ResolveObject,
|
||||||
SaveSiteConfig,
|
SaveSiteConfig,
|
||||||
Search,
|
Search,
|
||||||
|
@ -584,6 +588,34 @@ export class LemmyWebsocket {
|
||||||
blockCommunity(form: BlockCommunity) {
|
blockCommunity(form: BlockCommunity) {
|
||||||
return wrapper(UserOperation.BlockCommunity, form);
|
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) {
|
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||||
|
|
Loading…
Reference in a new issue