diff --git a/src/http.ts b/src/http.ts index 531bd1c..8cd1b45 100644 --- a/src/http.ts +++ b/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 { + return this.wrapper(HttpType.Post, '/admin/purge/person', form); + } + + /** + * Purge / Delete a community from the database. + */ + async purgeCommunity(form: PurgeCommunity): Promise { + return this.wrapper(HttpType.Post, '/admin/purge/community', form); + } + + /** + * Purge / Delete a post from the database. + */ + async purgePost(form: PurgePost): Promise { + return this.wrapper(HttpType.Post, '/admin/purge/post', form); + } + + /** + * Purge / Delete a comment from the database. + */ + async purgeComment(form: PurgeComment): Promise { + return this.wrapper(HttpType.Post, '/admin/purge/comment', form); + } + private buildFullUrl(endpoint: string): string { return `${this.apiUrl}${endpoint}`; } diff --git a/src/interfaces/api/site.ts b/src/interfaces/api/site.ts index aaa3c72..ddbde0b 100644 --- a/src/interfaces/api/site.ts +++ b/src/interfaces/api/site.ts @@ -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; +} diff --git a/src/interfaces/others.ts b/src/interfaces/others.ts index 4af1fe6..8ac088e 100644 --- a/src/interfaces/others.ts +++ b/src/interfaces/others.ts @@ -67,6 +67,10 @@ export enum UserOperation { GetSiteMetadata, BlockCommunity, BlockPerson, + PurgePerson, + PurgeCommunity, + PurgePost, + PurgeComment, CreateCommentReport, ResolveCommentReport, ListCommentReports, diff --git a/src/interfaces/source.ts b/src/interfaces/source.ts index dae9651..fd800fd 100644 --- a/src/interfaces/source.ts +++ b/src/interfaces/source.ts @@ -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; diff --git a/src/interfaces/views.ts b/src/interfaces/views.ts index 7ffa61e..c83e8d3 100644 --- a/src/interfaces/views.ts +++ b/src/interfaces/views.ts @@ -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; diff --git a/src/websocket.ts b/src/websocket.ts index 829cefe..eb8f5a2 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -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(op: UserOperation, data: MessageType) {