mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-12-23 03:11:26 +00:00
Admin purge (#35)
* Adding admin purge to API. * v0.13.4-rc.2 * v0.17.0-rc.10 * v0.17.0-rc.12 * Fixing a few purge issues. * v0.17.0-rc.33
This commit is contained in:
parent
adf324df19
commit
e7f5a5d05f
7 changed files with 244 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "lemmy-js-client",
|
"name": "lemmy-js-client",
|
||||||
"description": "A javascript / typescript client for Lemmy",
|
"description": "A javascript / typescript client for Lemmy",
|
||||||
"version": "0.17.0-rc.32",
|
"version": "0.17.0-rc.33",
|
||||||
"author": "Dessalines <tyhou13@gmx.com>",
|
"author": "Dessalines <tyhou13@gmx.com>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|
61
src/http.ts
61
src/http.ts
|
@ -115,6 +115,11 @@ import {
|
||||||
LeaveAdmin,
|
LeaveAdmin,
|
||||||
ListRegistrationApplications,
|
ListRegistrationApplications,
|
||||||
ListRegistrationApplicationsResponse,
|
ListRegistrationApplicationsResponse,
|
||||||
|
PurgeComment,
|
||||||
|
PurgeCommunity,
|
||||||
|
PurgeItemResponse,
|
||||||
|
PurgePerson,
|
||||||
|
PurgePost,
|
||||||
RegistrationApplicationResponse,
|
RegistrationApplicationResponse,
|
||||||
ResolveObject,
|
ResolveObject,
|
||||||
ResolveObjectResponse,
|
ResolveObjectResponse,
|
||||||
|
@ -1025,6 +1030,62 @@ export class LemmyHttp {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purge / Delete a person from the database.
|
||||||
|
*
|
||||||
|
* `HTTP.POST /admin/purge/person`
|
||||||
|
*/
|
||||||
|
async purgePerson(form: PurgePerson) {
|
||||||
|
return this.wrapper(
|
||||||
|
HttpType.Post,
|
||||||
|
"/admin/purge/person",
|
||||||
|
form,
|
||||||
|
PurgeItemResponse
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purge / Delete a community from the database.
|
||||||
|
*
|
||||||
|
* `HTTP.POST /admin/purge/community`
|
||||||
|
*/
|
||||||
|
async purgeCommunity(form: PurgeCommunity) {
|
||||||
|
return this.wrapper(
|
||||||
|
HttpType.Post,
|
||||||
|
"/admin/purge/community",
|
||||||
|
form,
|
||||||
|
PurgeItemResponse
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purge / Delete a post from the database.
|
||||||
|
*
|
||||||
|
* `HTTP.POST /admin/purge/post`
|
||||||
|
*/
|
||||||
|
async purgePost(form: PurgePost) {
|
||||||
|
return this.wrapper(
|
||||||
|
HttpType.Post,
|
||||||
|
"/admin/purge/post",
|
||||||
|
form,
|
||||||
|
PurgeItemResponse
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purge / Delete a comment from the database.
|
||||||
|
*
|
||||||
|
* `HTTP.POST /admin/purge/comment`
|
||||||
|
*/
|
||||||
|
async purgeComment(form: PurgeComment) {
|
||||||
|
return this.wrapper(
|
||||||
|
HttpType.Post,
|
||||||
|
"/admin/purge/comment",
|
||||||
|
form,
|
||||||
|
PurgeItemResponse
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private buildFullUrl(endpoint: string): string {
|
private buildFullUrl(endpoint: string): string {
|
||||||
return `${this.apiUrl}${endpoint}`;
|
return `${this.apiUrl}${endpoint}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,10 @@ import "reflect-metadata";
|
||||||
import { toOption, toUndefined } from "../../utils";
|
import { toOption, toUndefined } from "../../utils";
|
||||||
import { ListingType, SearchType, SortType } from "../others";
|
import { ListingType, SearchType, SortType } from "../others";
|
||||||
import {
|
import {
|
||||||
|
AdminPurgeCommentView,
|
||||||
|
AdminPurgeCommunityView,
|
||||||
|
AdminPurgePersonView,
|
||||||
|
AdminPurgePostView,
|
||||||
CommentView,
|
CommentView,
|
||||||
CommunityBlockView,
|
CommunityBlockView,
|
||||||
CommunityFollowerView,
|
CommunityFollowerView,
|
||||||
|
@ -140,6 +144,14 @@ export class GetModlogResponse {
|
||||||
transferred_to_community: ModTransferCommunityView[];
|
transferred_to_community: ModTransferCommunityView[];
|
||||||
@Type(() => ModAddView)
|
@Type(() => ModAddView)
|
||||||
added: ModAddView[];
|
added: ModAddView[];
|
||||||
|
@Type(() => AdminPurgePersonView)
|
||||||
|
admin_purged_persons: AdminPurgePersonView[];
|
||||||
|
@Type(() => AdminPurgeCommunityView)
|
||||||
|
admin_purged_communities: AdminPurgeCommunityView[];
|
||||||
|
@Type(() => AdminPurgePostView)
|
||||||
|
admin_purged_posts: AdminPurgePostView[];
|
||||||
|
@Type(() => AdminPurgeCommentView)
|
||||||
|
admin_purged_comments: AdminPurgeCommentView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateSite {
|
export class CreateSite {
|
||||||
|
@ -398,6 +410,62 @@ export class ResolveObjectResponse {
|
||||||
person: Option<PersonViewSafe>;
|
person: Option<PersonViewSafe>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class PurgePerson {
|
||||||
|
person_id: number;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: PurgePerson) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PurgeCommunity {
|
||||||
|
community_id: number;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: PurgeCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PurgePost {
|
||||||
|
post_id: number;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: PurgePost) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PurgeComment {
|
||||||
|
comment_id: number;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: PurgeComment) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PurgeItemResponse {
|
||||||
|
success: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export class ListRegistrationApplications {
|
export class ListRegistrationApplications {
|
||||||
/**
|
/**
|
||||||
* Only shows the unread applications (IE those without an admin actor)
|
* Only shows the unread applications (IE those without an admin actor)
|
||||||
|
|
|
@ -73,6 +73,10 @@ export enum UserOperation {
|
||||||
GetSiteMetadata,
|
GetSiteMetadata,
|
||||||
BlockCommunity,
|
BlockCommunity,
|
||||||
BlockPerson,
|
BlockPerson,
|
||||||
|
PurgePerson,
|
||||||
|
PurgeCommunity,
|
||||||
|
PurgePost,
|
||||||
|
PurgeComment,
|
||||||
CreateCommentReport,
|
CreateCommentReport,
|
||||||
ResolveCommentReport,
|
ResolveCommentReport,
|
||||||
ListCommentReports,
|
ListCommentReports,
|
||||||
|
|
|
@ -350,6 +350,48 @@ export class ModAdd {
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class AdminPurgePerson {
|
||||||
|
id: number;
|
||||||
|
admin_person_id: number;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
|
when_: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AdminPurgeCommunity {
|
||||||
|
id: number;
|
||||||
|
admin_person_id: number;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
|
when_: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AdminPurgePost {
|
||||||
|
id: number;
|
||||||
|
admin_person_id: number;
|
||||||
|
community_id: number;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
|
when_: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AdminPurgeComment {
|
||||||
|
id: number;
|
||||||
|
admin_person_id: number;
|
||||||
|
post_id: number;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
|
when_: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class CommunitySafe {
|
export class CommunitySafe {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -11,6 +11,10 @@ import {
|
||||||
} from "./aggregates";
|
} from "./aggregates";
|
||||||
import { SubscribedType } from "./others";
|
import { SubscribedType } from "./others";
|
||||||
import {
|
import {
|
||||||
|
AdminPurgeComment,
|
||||||
|
AdminPurgeCommunity,
|
||||||
|
AdminPurgePerson,
|
||||||
|
AdminPurgePost,
|
||||||
Comment,
|
Comment,
|
||||||
CommentReport,
|
CommentReport,
|
||||||
CommunitySafe,
|
CommunitySafe,
|
||||||
|
@ -289,6 +293,38 @@ export class ModStickyPostView {
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class AdminPurgeCommunityView {
|
||||||
|
@Type(() => AdminPurgeCommunity)
|
||||||
|
admin_purge_community: AdminPurgeCommunity;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
|
admin: PersonSafe;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AdminPurgePersonView {
|
||||||
|
@Type(() => AdminPurgePerson)
|
||||||
|
admin_purge_person: AdminPurgePerson;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
|
admin: PersonSafe;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AdminPurgePostView {
|
||||||
|
@Type(() => AdminPurgePost)
|
||||||
|
admin_purge_post: AdminPurgePost;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
|
admin: PersonSafe;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
|
community: CommunitySafe;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AdminPurgeCommentView {
|
||||||
|
@Type(() => AdminPurgeComment)
|
||||||
|
admin_purge_comment: AdminPurgeComment;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
|
admin: PersonSafe;
|
||||||
|
@Type(() => Post)
|
||||||
|
post: Post;
|
||||||
|
}
|
||||||
|
|
||||||
export class CommunityFollowerView {
|
export class CommunityFollowerView {
|
||||||
@Type(() => CommunitySafe)
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
|
|
@ -77,6 +77,10 @@ import {
|
||||||
GetUnreadRegistrationApplicationCount,
|
GetUnreadRegistrationApplicationCount,
|
||||||
LeaveAdmin,
|
LeaveAdmin,
|
||||||
ListRegistrationApplications,
|
ListRegistrationApplications,
|
||||||
|
PurgeComment,
|
||||||
|
PurgeCommunity,
|
||||||
|
PurgePerson,
|
||||||
|
PurgePost,
|
||||||
ResolveObject,
|
ResolveObject,
|
||||||
Search,
|
Search,
|
||||||
} from "./interfaces/api/site";
|
} from "./interfaces/api/site";
|
||||||
|
@ -627,6 +631,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