Adding private message reporting.

This commit is contained in:
Dessalines 2022-09-27 22:49:25 -04:00
parent c254359ec8
commit fb05c205f6
7 changed files with 168 additions and 0 deletions

View file

@ -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.
*

View file

@ -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 {

View file

@ -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;

View file

@ -64,6 +64,9 @@ export enum UserOperation {
EditPrivateMessage,
DeletePrivateMessage,
MarkPrivateMessageAsRead,
CreatePrivateMessageReport,
ResolvePrivateMessageReport,
ListPrivateMessageReports,
GetPrivateMessages,
UserJoin,
GetComments,

View file

@ -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>;
}

View file

@ -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>;
}

View file

@ -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.
*/