mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-29 07:41:12 +00:00
Private message report (#78)
* Adding private message reporting. * v0.17.0-rc.46
This commit is contained in:
parent
c254359ec8
commit
00189a6462
8 changed files with 169 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "lemmy-js-client",
|
||||
"description": "A javascript / typescript client for Lemmy",
|
||||
"version": "0.17.0-rc.45",
|
||||
"version": "0.17.0-rc.46",
|
||||
"author": "Dessalines <tyhou13@gmx.com>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/index.js",
|
||||
|
|
47
src/http.ts
47
src/http.ts
|
@ -45,6 +45,7 @@ import {
|
|||
BlockPersonResponse,
|
||||
ChangePassword,
|
||||
CreatePrivateMessage,
|
||||
CreatePrivateMessageReport,
|
||||
DeleteAccount,
|
||||
DeleteAccountResponse,
|
||||
DeletePrivateMessage,
|
||||
|
@ -62,6 +63,8 @@ import {
|
|||
GetReportCountResponse,
|
||||
GetUnreadCount,
|
||||
GetUnreadCountResponse,
|
||||
ListPrivateMessageReports,
|
||||
ListPrivateMessageReportsResponse,
|
||||
Login,
|
||||
LoginResponse,
|
||||
MarkAllAsRead,
|
||||
|
@ -72,9 +75,11 @@ import {
|
|||
PasswordReset,
|
||||
PasswordResetResponse,
|
||||
PersonMentionResponse,
|
||||
PrivateMessageReportResponse,
|
||||
PrivateMessageResponse,
|
||||
PrivateMessagesResponse,
|
||||
Register,
|
||||
ResolvePrivateMessageReport,
|
||||
SaveUserSettings,
|
||||
VerifyEmail,
|
||||
VerifyEmailResponse,
|
||||
|
@ -731,6 +736,48 @@ export class LemmyHttp {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a report for a private message.
|
||||
*
|
||||
* `HTTP.POST /private_message/report`
|
||||
*/
|
||||
async createPrivateMessageReport(form: CreatePrivateMessageReport) {
|
||||
return this.wrapper(
|
||||
HttpType.Post,
|
||||
"/private_message/report",
|
||||
form,
|
||||
PrivateMessageReportResponse
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a report for a private message.
|
||||
*
|
||||
* `HTTP.PUT /private_message/report/resolve`
|
||||
*/
|
||||
async resolvePrivateMessageReport(form: ResolvePrivateMessageReport) {
|
||||
return this.wrapper(
|
||||
HttpType.Put,
|
||||
"/private_message/report/resolve",
|
||||
form,
|
||||
PrivateMessageReportResponse
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List private message reports.
|
||||
*
|
||||
* `HTTP.GET /private_message/report/list`
|
||||
*/
|
||||
async listPrivateMessageReports(form: ListPrivateMessageReports) {
|
||||
return this.wrapper(
|
||||
HttpType.Get,
|
||||
"/private_message/report/list",
|
||||
form,
|
||||
ListPrivateMessageReportsResponse
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new user.
|
||||
*
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
PersonMentionView,
|
||||
PersonViewSafe,
|
||||
PostView,
|
||||
PrivateMessageReportView,
|
||||
PrivateMessageView,
|
||||
} from "../views";
|
||||
|
||||
|
@ -529,6 +530,57 @@ export class PrivateMessageResponse {
|
|||
private_message_view: PrivateMessageView;
|
||||
}
|
||||
|
||||
export class CreatePrivateMessageReport {
|
||||
private_message_id: number;
|
||||
reason: string;
|
||||
auth: string;
|
||||
|
||||
constructor(init: CreatePrivateMessageReport) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class PrivateMessageReportResponse {
|
||||
@Type(() => PrivateMessageReportView)
|
||||
private_message_report_view: PrivateMessageReportView;
|
||||
}
|
||||
|
||||
export class ResolvePrivateMessageReport {
|
||||
report_id: number;
|
||||
resolved: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: ResolvePrivateMessageReport) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class ListPrivateMessageReports {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
/// Only shows the unresolved reports
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unresolved_only: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: ListPrivateMessageReports) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class ListPrivateMessageReportsResponse {
|
||||
@Type(() => PrivateMessageReportView)
|
||||
private_message_reports: PrivateMessageReportView[];
|
||||
}
|
||||
|
||||
export class GetReportCount {
|
||||
/**
|
||||
* If a community is supplied, returns the report count for only that community, otherwise returns the report count for all communities the user moderates.
|
||||
|
@ -551,6 +603,10 @@ export class GetReportCountResponse {
|
|||
community_id: Option<number>;
|
||||
comment_reports: number;
|
||||
post_reports: number;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
private_message_reports: Option<number>;
|
||||
}
|
||||
|
||||
export class GetUnreadCount {
|
||||
|
|
|
@ -297,6 +297,9 @@ export class EditSite {
|
|||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
application_email_admins: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
hide_modlog_mod_names: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
|
|
|
@ -64,6 +64,9 @@ export enum UserOperation {
|
|||
EditPrivateMessage,
|
||||
DeletePrivateMessage,
|
||||
MarkPrivateMessageAsRead,
|
||||
CreatePrivateMessageReport,
|
||||
ResolvePrivateMessageReport,
|
||||
ListPrivateMessageReports,
|
||||
GetPrivateMessages,
|
||||
UserJoin,
|
||||
GetComments,
|
||||
|
|
|
@ -500,3 +500,21 @@ export class Language {
|
|||
code: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export class PrivateMessageReport {
|
||||
id: number;
|
||||
creator_id: number;
|
||||
private_message_id: number;
|
||||
original_pm_text: string;
|
||||
reason: string;
|
||||
resolved: boolean;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
resolver_id: Option<number>;
|
||||
published: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import {
|
|||
Post,
|
||||
PostReport,
|
||||
PrivateMessage,
|
||||
PrivateMessageReport,
|
||||
RegistrationApplication,
|
||||
Site,
|
||||
} from "./source";
|
||||
|
@ -450,3 +451,19 @@ export interface CommentNode {
|
|||
children: CommentNode[];
|
||||
depth: number;
|
||||
}
|
||||
|
||||
export class PrivateMessageReportView {
|
||||
@Type(() => PrivateMessageReport)
|
||||
private_message_report: PrivateMessageReport;
|
||||
@Type(() => PrivateMessage)
|
||||
private_message: PrivateMessage;
|
||||
@Type(() => PersonSafe)
|
||||
private_message_creator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PersonSafe)
|
||||
resolver: Option<PersonSafe>;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import {
|
|||
BlockPerson,
|
||||
ChangePassword,
|
||||
CreatePrivateMessage,
|
||||
CreatePrivateMessageReport,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
|
@ -40,6 +41,7 @@ import {
|
|||
GetReplies,
|
||||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
ListPrivateMessageReports,
|
||||
Login,
|
||||
MarkAllAsRead,
|
||||
MarkCommentReplyAsRead,
|
||||
|
@ -48,6 +50,7 @@ import {
|
|||
PasswordChange,
|
||||
PasswordReset,
|
||||
Register,
|
||||
ResolvePrivateMessageReport,
|
||||
SaveUserSettings,
|
||||
VerifyEmail,
|
||||
} from "./interfaces/api/person";
|
||||
|
@ -618,6 +621,27 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.GetPrivateMessages, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a report for a private message.
|
||||
*/
|
||||
createPrivateMessageReport(form: CreatePrivateMessageReport) {
|
||||
return wrapper(UserOperation.CreatePrivateMessageReport, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a report for a private message.
|
||||
*/
|
||||
resolvePrivateMessageReport(form: ResolvePrivateMessageReport) {
|
||||
return wrapper(UserOperation.ResolvePrivateMessageReport, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* List private message reports.
|
||||
*/
|
||||
listPrivateMessageReports(form: ListPrivateMessageReports) {
|
||||
return wrapper(UserOperation.ListPrivateMessageReports, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Block a person.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue