mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add log for send-mail-error
This commit is contained in:
1 parent
a81d514b10
commit
72998f643b
4 files changed
+20
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.20.1",
|
"version": "2.20.2",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { PERM, PRIV } from '../model/builtin';
|
|||||||
import {
|
import {
|
||||||
Route, Handler, Types, param,
|
Route, Handler, Types, param,
|
||||||
} from '../service/server';
|
} from '../service/server';
|
||||||
|
import * as bus from '../service/bus';
|
||||||
import { isTitle, isContent } from '../lib/validator';
|
import { isTitle, isContent } from '../lib/validator';
|
||||||
|
|
||||||
export const typeMapper = {
|
export const typeMapper = {
|
||||||
@@ -165,6 +166,11 @@ class DiscussionCreateHandler extends DiscussionHandler {
|
|||||||
else name = _name;
|
else name = _name;
|
||||||
if (highlight) this.checkPerm(PERM.PERM_HIGHLIGHT_DISCUSSION);
|
if (highlight) this.checkPerm(PERM.PERM_HIGHLIGHT_DISCUSSION);
|
||||||
if (pin) this.checkPerm(PERM.PERM_PIN_DISCUSSION);
|
if (pin) this.checkPerm(PERM.PERM_PIN_DISCUSSION);
|
||||||
|
await bus.serial(
|
||||||
|
'discussion/before-add',
|
||||||
|
domainId, typeMapper[type], name, this.user._id,
|
||||||
|
title, content, this.request.ip, highlight, pin,
|
||||||
|
);
|
||||||
const did = await discussion.add(
|
const did = await discussion.add(
|
||||||
domainId, typeMapper[type], name, this.user._id,
|
domainId, typeMapper[type], name, this.user._id,
|
||||||
title, content, this.request.ip, highlight, pin,
|
title, content, this.request.ip, highlight, pin,
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import nodemailer from 'nodemailer';
|
import nodemailer from 'nodemailer';
|
||||||
import { SendMailError } from '../error';
|
import { SendMailError } from '../error';
|
||||||
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
|
const logger = new Logger('mail');
|
||||||
|
|
||||||
export async function sendMail(to: string, subject: string, text: string, html: string) {
|
export async function sendMail(to: string, subject: string, text: string, html: string) {
|
||||||
let t: unknown;
|
let t: unknown;
|
||||||
@@ -29,6 +32,7 @@ export async function sendMail(to: string, subject: string, text: string, html:
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
logger.error(e);
|
||||||
throw new SendMailError(to);
|
throw new SendMailError(to);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
import cluster from 'cluster';
|
import cluster from 'cluster';
|
||||||
import { Db, FilterQuery, OnlyFieldsOfType } from 'mongodb';
|
import type {
|
||||||
|
Db, FilterQuery, ObjectID, OnlyFieldsOfType,
|
||||||
|
} from 'mongodb';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import type {
|
import type {
|
||||||
@@ -57,6 +59,12 @@ export interface EventMap {
|
|||||||
$set: any, $unset: OnlyFieldsOfType<DocType[T], any, true | '' | 1>
|
$set: any, $unset: OnlyFieldsOfType<DocType[T], any, true | '' | 1>
|
||||||
) => VoidReturn
|
) => VoidReturn
|
||||||
|
|
||||||
|
'discussion/before-add': (
|
||||||
|
domainId: string, parentType: number, parentId: ObjectID | number | string,
|
||||||
|
owner: number, title: string, content: string,
|
||||||
|
ip: string | null, highlight: boolean, pin: boolean
|
||||||
|
) => VoidReturn
|
||||||
|
|
||||||
'problem/before-edit': (doc: Partial<Pdoc>) => VoidReturn
|
'problem/before-edit': (doc: Partial<Pdoc>) => VoidReturn
|
||||||
'problem/edit': (doc: Pdoc) => VoidReturn
|
'problem/edit': (doc: Pdoc) => VoidReturn
|
||||||
'problem/list': (query: FilterQuery<Pdoc>, handler: any) => VoidReturn
|
'problem/list': (query: FilterQuery<Pdoc>, handler: any) => VoidReturn
|
||||||
|
|||||||
Reference in new issue
Block a user