Helptickets: Make PMHarassment a text ticket type

This commit is contained in:
Mia 2021-05-17 14:35:39 -05:00
parent 28023bc0d7
commit d2c4eaf67e

View File

@ -35,7 +35,9 @@ interface TextTicketInfo {
input: string, context: string, pageId: string, user: User, reportTarget?: string
) => boolean | string[] | Promise<boolean | string[]>;
title: string;
getReviewDisplay: (ticket: TicketState & {text: [string, string]}, staff: User, conn: Connection) => string | void;
getReviewDisplay: (
ticket: TicketState & {text: [string, string]}, staff: User, conn: Connection
) => Promise<string | void> | string | void;
onSubmit?: (ticket: TicketState, text: [string, string], submitter: User, conn: Connection) => void;
}
@ -713,6 +715,43 @@ const cheatingScenarios = [
];
export const textTickets: {[k: string]: TextTicketInfo} = {
pmharassment: {
title: "Who's harassing you in PMs?",
checker(input) {
if (!Users.get(input)) {
return ['That user was not found.'];
}
return true;
},
getReviewDisplay(ticket, staff, conn) {
let buf = '';
const sharedBattles = getCommonBattles(ticket.userid, null, toID(ticket.text[0]), null, conn);
const replays = getBattleLinks(ticket.text[1]).concat(getBattleLinks(ticket.text[1]));
buf += `<strong>Reported user:</strong> ${ticket.text[0]}</br />`;
buf += `<br /><br /><details class="readmore"><summary><strong>Punish:</strong></summary><div class="infobox">`;
const replayString = replays.concat(sharedBattles).map(u => `https://${Config.routes.replays}/${u}`).join(', ');
const proofString = `spoiler:PMs with ${ticket.userid}${replayString ? `, ${replayString}` : ''}`;
for (const [name, punishment] of [['Lock', 'lock'], ['Weeklock', 'weeklock'], ['Warn', 'warn']]) {
buf += `<form data-submitsend="/msgroom staff,/${punishment} ${ticket.text[0]},{reason} ${proofString}">`;
buf += `<button class="button notifying" type="submit">${name}</button><br />`;
buf += `Optional reason: <input name="reason" />`;
buf += `</form><br />`;
}
buf += `</div></details><br />`;
if (sharedBattles.length) {
buf += `<details class="readmore"><summary>Shared battles</summary>`;
buf += sharedBattles.map(url => `<<${url}>>`).join(', ');
buf += `</details>`;
}
if (replays.length) {
buf += `<details class="readmore"><summary>Battle links</summary>`;
buf += replays.map(url => `<<${url}>>`).join(', ');
buf += `</details>`;
}
return buf;
},
},
inapname: {
title: "What's the inappropriate username?",
checker(input) {
@ -1157,7 +1196,7 @@ export const pages: Chat.PageTable = {
buf += `</tbody></table></div>`;
return buf;
},
text(query, user, connection) {
async text(query, user, connection) {
if (!user.named) return Rooms.RETRY_AFTER_LOGIN;
this.title = this.tr`Queued Tickets`;
this.checkCan('lock');
@ -1188,7 +1227,7 @@ export const pages: Chat.PageTable = {
} else if (ticket.claimed) {
buf += `<strong>Claimed:</strong> ${ticket.claimed}<br />`;
}
buf += ticketInfo.getReviewDisplay(ticket as TicketState & {text: [string, string]}, user, connection);
buf += await ticketInfo.getReviewDisplay(ticket as TicketState & {text: [string, string]}, user, connection);
buf += `<br />`;
buf += `<div class="infobox">`;
const [text, context] = ticket.text;