fix: apply link email mark optional

This commit is contained in:
Innei
2021-10-04 16:45:10 +08:00
parent aa7e322baa
commit 523702f779
4 changed files with 13 additions and 8 deletions

View File

@@ -67,7 +67,7 @@ export class LinkController {
process.nextTick(async () => {
if (doc.email) {
this.linkService.sendToCandidate(doc)
await this.linkService.sendToCandidate(doc)
}
})
return

View File

@@ -1,5 +1,6 @@
import { ApiProperty } from '@nestjs/swagger'
import { modelOptions, prop } from '@typegoose/typegoose'
import { Transform } from 'class-transformer'
import { IsEmail, IsEnum, IsOptional, IsString, IsUrl } from 'class-validator'
import { range } from 'lodash'
import { BaseModel } from '~/shared/model/base.model'
@@ -32,6 +33,8 @@ export class LinkModel extends BaseModel {
@IsOptional()
@IsUrl({ require_protocol: true })
@prop({ trim: true })
// 对空字符串处理
@Transform(({ value }) => (value === '' ? null : value))
avatar?: string
@IsOptional()
@@ -52,6 +55,9 @@ export class LinkModel extends BaseModel {
@prop()
@IsEmail()
@IsOptional()
// 对空字符串处理
@Transform(({ value }) => (value === '' ? null : value))
email?: string
get hide() {
return this.state === LinkState.Audit

View File

@@ -84,12 +84,11 @@ export class LinkService {
站点描述: ${model.description}`)
return
}
process.nextTick(async () => {
await this.emailService.sendLinkApplyEmail({
model,
to: model.email,
template: LinkApplyEmailType.ToCandidate,
})
await this.emailService.sendLinkApplyEmail({
model,
to: model.email,
template: LinkApplyEmailType.ToCandidate,
})
}
async sendToMaster(authorName: string, model: LinkModel) {

View File

@@ -117,7 +117,7 @@ export class PageProxyController {
`<!-- injectable script -->`,
`<script>${`window.page_source='${
source.from
}'};\nwindow.injectData = ${JSON.stringify({
}';\nwindow.injectData = ${JSON.stringify({
LOGIN_BG: adminExtra.background,
TITLE: adminExtra.title,
WEB_URL: webUrl,