邮件通知区分测试和正式
This commit is contained in:
parent
8ade5239df
commit
b99515089b
@ -2,6 +2,13 @@
|
||||
{
|
||||
"id": 421613,
|
||||
"key": "0xd9ed33809372932059c1ba7b336a33f406b4c55e7430daef8297134c67429d60",
|
||||
"wallet": "0xE68F149daF2F314d9960c08496D8701BC7671850"
|
||||
"wallet": "0xE68F149daF2F314d9960c08496D8701BC7671850",
|
||||
"mail": "zhl010101@gmail.com"
|
||||
},
|
||||
{
|
||||
"id": 42161,
|
||||
"key": "0x0d6b3b1402f72b204f93e1438fbad4713a838b21c13c16f50ff54c32a8917273",
|
||||
"wallet": "0x3Cd052Cc25358DB844bcDDfFa514080d41a4c2cA",
|
||||
"mail": "ztgame@gmail.com"
|
||||
}
|
||||
]
|
||||
|
14
config/chains_exec.json
Normal file
14
config/chains_exec.json
Normal file
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"id": 421613,
|
||||
"key": "0xd9ed33809372932059c1ba7b336a33f406b4c55e7430daef8297134c67429d60",
|
||||
"wallet": "0xE68F149daF2F314d9960c08496D8701BC7671850",
|
||||
"mail": "zhl010101@gmail.com"
|
||||
},
|
||||
{
|
||||
"id": 42161,
|
||||
"key": "0x360876d3c243266436e7853ec9d170ab312a7c89465cc8e17d66e7094de60ccf",
|
||||
"wallet": "0x3Cd052Cc25358DB844bcDDfFa514080d41a4c2cA",
|
||||
"mail": "ztgame@gmail.com"
|
||||
}
|
||||
]
|
@ -6,5 +6,13 @@
|
||||
"fromBlock": 30117942,
|
||||
"eventProcesser": "ScheduleConfirmEvent",
|
||||
"chain": 421613
|
||||
},
|
||||
{
|
||||
"address": "0x3Cd052Cc25358DB844bcDDfFa514080d41a4c2cA",
|
||||
"event": "Confirmation",
|
||||
"abi": "BEMultiSigWallet",
|
||||
"fromBlock": 110368018,
|
||||
"eventProcesser": "ScheduleConfirmEvent",
|
||||
"chain": 42161
|
||||
}
|
||||
]
|
||||
|
@ -10,6 +10,7 @@ import logger from 'logger/logger'
|
||||
import BlocknumSchedule from 'schedule/blocknum.schedule'
|
||||
import { RedisClient } from 'redis/RedisClient'
|
||||
import WxTaskSchedule from 'schedule/wxtask.schedule'
|
||||
import { ChainCache } from 'cache/ChainCache'
|
||||
|
||||
const zReqParserPlugin = require('plugins/zReqParser')
|
||||
|
||||
@ -21,7 +22,7 @@ const fs = require('fs')
|
||||
const join = require('path').join
|
||||
|
||||
require('./common/Extend')
|
||||
|
||||
new ChainCache().init('chains')
|
||||
export class ApiServer {
|
||||
server: FastifyInstance<Server, IncomingMessage, ServerResponse>
|
||||
|
||||
|
10
src/cache/ChainCache.ts
vendored
10
src/cache/ChainCache.ts
vendored
@ -6,12 +6,13 @@ import Web3 from 'web3'
|
||||
import { WalletReactor } from 'chain/WalletReactor'
|
||||
import { ConfirmQueue } from 'queue/confirm.queue'
|
||||
|
||||
const chainCfgs = require('../../config/chains.json')
|
||||
let chainCfgs = require('../../config/chains.json')
|
||||
|
||||
export interface IChainCfg {
|
||||
id: number
|
||||
key: string
|
||||
wallet: string
|
||||
mail: string
|
||||
}
|
||||
|
||||
@singleton
|
||||
@ -19,11 +20,10 @@ export class ChainCache {
|
||||
public providers: Map<number, Web3> = new Map()
|
||||
public wallets: Map<number, WalletReactor> = new Map()
|
||||
public confirmQueues: Map<number, ConfirmQueue> = new Map()
|
||||
constructor() {
|
||||
this.init()
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
private async init() {
|
||||
public async init(filename: string) {
|
||||
chainCfgs = require(`../../config/${filename}.json`)
|
||||
for (let cfg of chainCfgs) {
|
||||
let chainData = AllChains.find(o => o.id === cfg.id)
|
||||
assert(chainData, `chain id ${cfg.id} not found`)
|
||||
|
@ -133,7 +133,7 @@ export class ChainTaskClass extends BaseModule {
|
||||
}
|
||||
if (sCount === record.tasks.length) {
|
||||
// send mail to confirmer
|
||||
new MailQueue().addTaskToQueue(record)
|
||||
new MailQueue(record.chain).addTaskToQueue(record)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import { ScheduleConfirmEvent } from 'models/ScheduleConfirmEvent'
|
||||
import { ScheduleExecutedEvent } from 'models/ScheduleExecutedEvent'
|
||||
|
||||
import 'common/Extend'
|
||||
import { ChainCache } from 'cache/ChainCache'
|
||||
|
||||
let svrs: any[] = []
|
||||
let lock = false
|
||||
@ -23,6 +24,8 @@ let eventProcessers = {
|
||||
|
||||
const events = require('../config/events.json')
|
||||
|
||||
new ChainCache().init('chains_exec')
|
||||
|
||||
async function initEventSvrs() {
|
||||
// let nfts = [{ address: '0x37c30a2945799a53c5358636a721b442458fa691' }]
|
||||
for (let event of events) {
|
||||
|
@ -6,10 +6,12 @@ import { ChainTaskClass } from 'models/ChainTask'
|
||||
import { MailService } from 'service/mail.service'
|
||||
import { Deferred } from 'utils/promise.util'
|
||||
import { CONFIRM_MAIL_HTML } from 'common/Constants'
|
||||
import { ChainCache } from 'cache/ChainCache'
|
||||
import assert from 'assert'
|
||||
|
||||
export interface IMailData {
|
||||
from?: string
|
||||
to: string
|
||||
to?: string
|
||||
subject?: string
|
||||
text?: string
|
||||
html?: string
|
||||
@ -17,14 +19,15 @@ export interface IMailData {
|
||||
|
||||
const DEFAULT_MSG_DATA: IMailData = {
|
||||
from: 'CEBG <noreply@cebg.games>',
|
||||
to: process.env.MAIL_DEFAULT_ADDRESS,
|
||||
subject: 'CEBG',
|
||||
}
|
||||
|
||||
@singleton
|
||||
export class MailQueue {
|
||||
private queue: AsyncQueue
|
||||
constructor() {
|
||||
private chain: number
|
||||
constructor(chain: number) {
|
||||
this.chain = chain
|
||||
this.queue = createAsyncQueue()
|
||||
}
|
||||
|
||||
@ -37,7 +40,9 @@ export class MailQueue {
|
||||
let link2 = `${process.env.WEB_BASE_URL}/pages/confirm.html?id=${task.id}`
|
||||
html = html.replace('{{link2}}', link2)
|
||||
let subject = `${task.starterName} 申请 ${task.name}`
|
||||
let data: any = { html, subject }
|
||||
let cfg = new ChainCache().chainArray.find(c => c.id === this.chain)
|
||||
assert(cfg, `chain ${this.chain} not found`)
|
||||
let data: any = { html, subject, to: cfg.mail }
|
||||
Object(DEFAULT_MSG_DATA).zssign(data)
|
||||
let deferred = new Deferred()
|
||||
this.queue.push(async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user