Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions config/service.report.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"rest:report:api"
],
"restUrl": "https://api-pub.bitfinex.com",
"emailConf": {
"from": "Bitfinex <no-reply@bitfinex.com>",
"subject": "Your report is ready"
},
"s3Conf": {
"bucket": "",
"acl": "",
Expand Down
15 changes: 0 additions & 15 deletions locales/en/email.json

This file was deleted.

15 changes: 0 additions & 15 deletions locales/es-EM/email.json

This file was deleted.

15 changes: 0 additions & 15 deletions locales/pt-BR/email.json

This file was deleted.

15 changes: 0 additions & 15 deletions locales/ru/email.json

This file was deleted.

15 changes: 0 additions & 15 deletions locales/tr/email.json

This file was deleted.

15 changes: 0 additions & 15 deletions locales/zh-CN/email.json

This file was deleted.

15 changes: 0 additions & 15 deletions locales/zh-TW/email.json

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-report",
"version": "4.13.1",
"version": "4.13.2",
"description": "Reporting tool",
"main": "worker.js",
"license": "Apache-2.0",
Expand Down Expand Up @@ -70,8 +70,7 @@
".idea/",
".vscode/",
"csv/",
"workers/loc.api/queue/temp/",
"workers/loc.api/queue/views/"
"workers/loc.api/queue/temp/"
]
},
"betterScripts": {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/helpers.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const startHelpers = (
logs,
workers = [
{ name: 's3', port: 13371 },
{ name: 'sendgrid', port: 1310 },
{ name: 'mail', port: 1310 },
{ name: 'gpg', port: 1320 },
{ name: 'pdf', port: 1330 },
{ name: 'testcalls', port: 1300 }
Expand Down
43 changes: 43 additions & 0 deletions test/simulate/mocks-spies/mail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict'

const workerArgs = ['rest:core:mail']

function addFunctions (ExtApi) {
ExtApi.prototype.enqueueEmail = function (space, msg, cb) {
const {
lang,
to,
reportUrl,
fileName
} = msg?.payload

if (!msg?.type) return cb(new Error('ERR_API_NO_TYPE'))
if (!lang) return cb(new Error('ERR_API_NO_LANGUAGE'))
if (!to) return cb(new Error('ERR_API_NO_TO'))
if (!reportUrl) return cb(new Error('ERR_API_NO_REPORT_URL'))
if (!fileName) return cb(new Error('ERR_API_NO_FILE_NAME'))

try {
const res = ['send']
const grcBfx = this.ctx.grc_bfx
const call = {
worker: 'core.mail',
on: 'enqueueEmail',
params: { msg },
res: res[0],
timestamp: Date.now()
}
grcBfx.req('rest:ext:testcalls', 'addCall', [call], { timeout: 10000 }, (err, data) => {
if (err) cb(new Error('core.mail:enqueueEmail:testcalls'))
else return cb(null, res && res.length && res[0])
})
} catch (e) {
cb(new Error(`ERR_API_MAIL: ${e.toString()}`))
}
}
}

module.exports = {
addFunctions,
workerArgs
}
12 changes: 5 additions & 7 deletions test/simulate/mocks-spies/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ const workerArgs = ['rest:ext:s3']

function addFunctions (ExtApi) {
ExtApi.prototype.uploadPresigned = function (space, data, opts, cb) {
const upload = {
public_url: 'https://fakeUrl.com',
key: 'fakeKey',
s3bucket: 'fakeBucket'
const mockedRes = {
presigned_url: 'https://fakePresignedUrl.com'
}
const grcBfx = this.ctx.grc_bfx
const call = {
worker: 'ext.s3',
on: 'uploadPresigned',
params: { opts },
res: { upload },
params: { data, opts },
res: mockedRes,
timestamp: Date.now()
}

Expand All @@ -25,7 +23,7 @@ function addFunctions (ExtApi) {
{ timeout: 10000 },
(err, data) => {
if (err) cb(new Error('ext.s3:uploadPresigned:testcalls'))
else return cb(null, upload)
else return cb(null, mockedRes)
}
)
}
Expand Down
42 changes: 0 additions & 42 deletions test/simulate/mocks-spies/sendgrid.js

This file was deleted.

3 changes: 1 addition & 2 deletions workers/loc.api/di/app.deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ module.exports = ({
bindDepsToFn(
sendMail,
[
TYPES.GrcBfxReq,
TYPES.I18next
TYPES.GrcBfxReq
]
)
)
Expand Down
2 changes: 1 addition & 1 deletion workers/loc.api/generate-report-file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const _getReportFileStoreStatus = async ({
}
}

if (!await hasGrcService.hasS3AndSendgrid()) {
if (!await hasGrcService.hasS3AndMailServices()) {
throw new EmailSendingError()
}
if (
Expand Down
8 changes: 4 additions & 4 deletions workers/loc.api/has.grc.service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ class HasGrcService {
}
}

async hasS3AndSendgrid () {
async hasS3AndMailServices () {
const countS3Services = await this.lookUpFunction(
'rest:ext:s3'
)
const countSendgridServices = await this.lookUpFunction(
'rest:ext:sendgrid'
const countMailServices = await this.lookUpFunction(
'rest:core:mail'
)

return !!(countS3Services && countSendgridServices)
return !!(countS3Services && countMailServices)
}

async hasGPGService () {
Expand Down
2 changes: 1 addition & 1 deletion workers/loc.api/i18next/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = (params) => {
default: ['en']
},
ns: Object.values(TRANSLATION_NAMESPACES),
defaultNS: 'email',
defaultNS: TRANSLATION_NAMESPACES.PDF,
preload: [...transPaths.reduce((accum, transPath) => {
const allFileNames = fs.readdirSync(transPath)

Expand Down
1 change: 0 additions & 1 deletion workers/loc.api/i18next/translation.namespaces.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const TRANSLATION_NAMESPACES = {
EMAIL: 'email',
PDF: 'pdf'
}

Expand Down
5 changes: 1 addition & 4 deletions workers/loc.api/queue/aggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ module.exports = (
email,
isUnauth,
s3Conf,
emailConf,
language
} = job.data

const isEnableToSendEmail = (
typeof email === 'string' &&
await hasGrcService.hasS3AndSendgrid()
await hasGrcService.hasS3AndMailServices()
)

const newFilePaths = []
Expand All @@ -55,9 +54,7 @@ module.exports = (
)

await sendMail(
emailConf,
email,
'email.pug',
s3Data.map((item, i) => ({
...item,
isUnauth,
Expand Down
1 change: 0 additions & 1 deletion workers/loc.api/queue/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ module.exports = (
processorQueue.on('completed', (result) => {
aggregatorQueue.addJob({
...result,
emailConf: conf.emailConf,
s3Conf: conf.s3Conf
})
})
Expand Down
Loading