Compare commits

...

8 commits

Author SHA1 Message Date
Dessalines
45ee499909 v0.17.0-rc.33 2022-06-23 14:44:01 -04:00
Dessalines
25da5108eb Fixing a few purge issues. 2022-06-23 14:43:44 -04:00
Dessalines
719f38b154 Merge branch 'main' into admin_purge 2022-06-23 10:48:01 -04:00
Dessalines
5cdc7c96a2 v0.17.0-rc.12 2022-06-02 17:48:41 -04:00
Dessalines
469643833a v0.17.0-rc.10 2022-06-02 17:48:26 -04:00
Dessalines
9c59fc2a31 Merge branch 'main' into admin_purge 2022-06-02 11:38:38 -04:00
Dessalines
a9b5f6fdfb v0.13.4-rc.2 2021-10-15 18:18:33 -04:00
Dessalines
51ef5ebceb Adding admin purge to API. 2021-10-15 18:17:42 -04:00
7 changed files with 244 additions and 1 deletions

View file

@ -1,7 +1,7 @@
{
"name": "lemmy-js-client",
"description": "A javascript / typescript client for Lemmy",
"version": "0.17.0-rc.32",
"version": "0.17.0-rc.33",
"author": "Dessalines <tyhou13@gmx.com>",
"license": "AGPL-3.0",
"main": "./dist/index.js",

View file

@ -115,6 +115,11 @@ import {
LeaveAdmin,
ListRegistrationApplications,
ListRegistrationApplicationsResponse,
PurgeComment,
PurgeCommunity,
PurgeItemResponse,
PurgePerson,
PurgePost,
RegistrationApplicationResponse,
ResolveObject,
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 {
return `${this.apiUrl}${endpoint}`;
}

View file

@ -4,6 +4,10 @@ import "reflect-metadata";
import { toOption, toUndefined } from "../../utils";
import { ListingType, SearchType, SortType } from "../others";
import {
AdminPurgeCommentView,
AdminPurgeCommunityView,
AdminPurgePersonView,
AdminPurgePostView,
CommentView,
CommunityBlockView,
CommunityFollowerView,
@ -140,6 +144,14 @@ export class GetModlogResponse {
transferred_to_community: ModTransferCommunityView[];
@Type(() => 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 {
@ -398,6 +410,62 @@ export class ResolveObjectResponse {
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 {
/**
* Only shows the unread applications (IE those without an admin actor)

View file

@ -73,6 +73,10 @@ export enum UserOperation {
GetSiteMetadata,
BlockCommunity,
BlockPerson,
PurgePerson,
PurgeCommunity,
PurgePost,
PurgeComment,
CreateCommentReport,
ResolveCommentReport,
ListCommentReports,

View file

@ -350,6 +350,48 @@ export class ModAdd {
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 {
id: number;
name: string;

View file

@ -11,6 +11,10 @@ import {
} from "./aggregates";
import { SubscribedType } from "./others";
import {
AdminPurgeComment,
AdminPurgeCommunity,
AdminPurgePerson,
AdminPurgePost,
Comment,
CommentReport,
CommunitySafe,
@ -289,6 +293,38 @@ export class ModStickyPostView {
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 {
@Type(() => CommunitySafe)
community: CommunitySafe;

View file

@ -77,6 +77,10 @@ import {
GetUnreadRegistrationApplicationCount,
LeaveAdmin,
ListRegistrationApplications,
PurgeComment,
PurgeCommunity,
PurgePerson,
PurgePost,
ResolveObject,
Search,
} from "./interfaces/api/site";
@ -627,6 +631,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) {