mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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",
|
||||
"version": "2.20.1",
|
||||
"version": "2.20.2",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -15,6 +15,7 @@ import { PERM, PRIV } from '../model/builtin';
|
||||
import {
|
||||
Route, Handler, Types, param,
|
||||
} from '../service/server';
|
||||
import * as bus from '../service/bus';
|
||||
import { isTitle, isContent } from '../lib/validator';
|
||||
|
||||
export const typeMapper = {
|
||||
@@ -165,6 +166,11 @@ class DiscussionCreateHandler extends DiscussionHandler {
|
||||
else name = _name;
|
||||
if (highlight) this.checkPerm(PERM.PERM_HIGHLIGHT_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(
|
||||
domainId, typeMapper[type], name, this.user._id,
|
||||
title, content, this.request.ip, highlight, pin,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import nodemailer from 'nodemailer';
|
||||
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) {
|
||||
let t: unknown;
|
||||
@@ -29,6 +32,7 @@ export async function sendMail(to: string, subject: string, text: string, html:
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error(e);
|
||||
throw new SendMailError(to);
|
||||
}
|
||||
return t;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import cluster from 'cluster';
|
||||
import { Db, FilterQuery, OnlyFieldsOfType } from 'mongodb';
|
||||
import type {
|
||||
Db, FilterQuery, ObjectID, OnlyFieldsOfType,
|
||||
} from 'mongodb';
|
||||
import { argv } from 'yargs';
|
||||
import { Logger } from '../logger';
|
||||
import type {
|
||||
@@ -57,6 +59,12 @@ export interface EventMap {
|
||||
$set: any, $unset: OnlyFieldsOfType<DocType[T], any, true | '' | 1>
|
||||
) => 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/edit': (doc: Pdoc) => VoidReturn
|
||||
'problem/list': (query: FilterQuery<Pdoc>, handler: any) => VoidReturn
|
||||
|
||||
Reference in new issue
Block a user