Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
9b5216431d
|
|||
|
1d5c00768c
|
|||
|
7f1c9ec9a8
|
@@ -12,7 +12,7 @@ class EMailJob extends Job {
|
||||
|
||||
const { data } = job
|
||||
let { from = config.default_sender, to, subject, html = undefined, email_params = undefined } = data
|
||||
this.output.info(`Sending mail to ${to}...`)
|
||||
this.info(`Sending mail to ${to}...`)
|
||||
|
||||
if ( !html && email_params ) html = this.email(email_params)
|
||||
|
||||
@@ -20,9 +20,11 @@ class EMailJob extends Job {
|
||||
from, to, subject, html,
|
||||
})
|
||||
} catch (e) {
|
||||
this.output.error(e)
|
||||
this.error(e)
|
||||
throw e
|
||||
}
|
||||
this.output.success(`Mail sent!`)
|
||||
|
||||
this.success(`Mail sent!`)
|
||||
}
|
||||
|
||||
email({ header_text, body_paragraphs = [], button_text = '', button_link = '' }) {
|
||||
|
||||
@@ -12,7 +12,7 @@ class ForeignIPLoginAlertJob extends Job {
|
||||
const user = await User.findById(user_id)
|
||||
if ( !user ) throw new Error('Unable to find user with ID: '+user_id)
|
||||
|
||||
this.output.info('Sending foreign IP login alert to user.')
|
||||
this.info('Sending foreign IP login alert to user ' + user.uid)
|
||||
|
||||
await this.jobs.queue('mailer').add('EMail', {
|
||||
to: user.email,
|
||||
@@ -29,14 +29,19 @@ class ForeignIPLoginAlertJob extends Job {
|
||||
}
|
||||
})
|
||||
|
||||
this.info('Logged e-mail job')
|
||||
|
||||
if ( user.notify_config && user.notify_config.active ) {
|
||||
await user.notify_config.log({
|
||||
title: `${this.configs.get('app.name')}: Sign-In From New IP`,
|
||||
message: `Someone signed into your account (${user.uid}) from the IP address ${ip}. If this was you, no further action is required.`,
|
||||
})
|
||||
|
||||
this.info('Logged push notification job')
|
||||
}
|
||||
} catch (e) {
|
||||
this.output.error(e)
|
||||
this.error(e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,17 @@ class PasswordResetJob extends Job {
|
||||
const User = this.models.get('auth:User')
|
||||
const user = await User.findById(user_id)
|
||||
if (!user) {
|
||||
this.output.error(`Unable to find user with ID: ${user_id}`)
|
||||
this.error(`Unable to find user with ID: ${user_id}`)
|
||||
throw new Error('Unable to find user with that ID.')
|
||||
}
|
||||
|
||||
this.output.info(`Resetting password for user: ${user.uid}`)
|
||||
this.info(`Resetting password for user: ${user.uid}`)
|
||||
|
||||
// Create an authenticated key-action
|
||||
const key_action = await this.key_action(user)
|
||||
|
||||
this.info(`Created reset keyaction ${key_action.id} (key: ${key_action.key}, handler: ${key_action.handler})`)
|
||||
|
||||
await this.jobs.queue('mailer').add('EMail', {
|
||||
to: user.email,
|
||||
subject: 'Reset Your Password | ' + this.configs.get('app.name'),
|
||||
@@ -34,17 +38,22 @@ class PasswordResetJob extends Job {
|
||||
}
|
||||
})
|
||||
|
||||
this.info('Logged e-mail job.')
|
||||
|
||||
if ( user.notify_config && user.notify_config.active ) {
|
||||
await user.notify_config.log({
|
||||
title: `${this.configs.get('app.name')}: Password Reset Requested`,
|
||||
message: `A password reset request was logged for your account (${user.uid}). If this was you, please check your e-mail for further instructions.`,
|
||||
priority: 8,
|
||||
})
|
||||
|
||||
this.info('Logged security push notification job')
|
||||
}
|
||||
|
||||
this.output.success('Password reset logged.')
|
||||
this.success('Password reset logged.')
|
||||
} catch (e) {
|
||||
this.output.error(e)
|
||||
this.error(e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class PasswordResetAlertJob extends Job {
|
||||
const user = await User.findById(user_id)
|
||||
if ( !user ) throw new Error('Unable to find user with ID: '+user_id)
|
||||
|
||||
this.output.info('Sending password reset alert to user.')
|
||||
this.info('Sending password reset alert to user ' + user.uid)
|
||||
|
||||
await this.jobs.queue('mailer').add('EMail', {
|
||||
to: user.email,
|
||||
@@ -28,15 +28,20 @@ class PasswordResetAlertJob extends Job {
|
||||
},
|
||||
})
|
||||
|
||||
this.info('Logged e-mail job')
|
||||
|
||||
if ( user.notify_config && user.notify_config.active ) {
|
||||
await user.notify_config.log({
|
||||
title: `${this.configs.get('app.name')}: Password Reset`,
|
||||
message: `The password to your account (${user.uid}) was reset from the IP address ${ip}. If this was not you, please contact your system administrator.`,
|
||||
priority: 8,
|
||||
})
|
||||
|
||||
this.info('Logged push notification job')
|
||||
}
|
||||
} catch (e) {
|
||||
this.output.error(e)
|
||||
this.error(e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,15 @@ class PopulateAnnouncementJob extends Job {
|
||||
const announcement = await Announcement.findById(announcement_id)
|
||||
|
||||
if ( !announcement ) {
|
||||
this.output.error(`Unable to find announcement with ID: ${announcement_id}`)
|
||||
this.error(`Unable to find announcement with ID: ${announcement_id}`)
|
||||
throw new Error('Unable to find announcement with that ID.')
|
||||
}
|
||||
|
||||
await announcement.populate()
|
||||
this.output.success('Populated announcements.')
|
||||
this.success('Populated announcements.')
|
||||
} catch (e) {
|
||||
this.output.error(e)
|
||||
this.error(e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,15 @@ class PushNotifyJob extends Job {
|
||||
const notify = user.notify_config
|
||||
if ( !notify || !notify.active ) throw new Error('User does not have notifications configured.')
|
||||
|
||||
this.output.info(`Sending notification to ${user.uid}...`)
|
||||
this.info(`Sending notification to ${user.uid}...`)
|
||||
|
||||
await notify.send({ title, message, priority })
|
||||
} catch (e) {
|
||||
this.output.error(e)
|
||||
this.error(e)
|
||||
throw e
|
||||
}
|
||||
this.output.success(`Notification sent!`)
|
||||
|
||||
this.success(`Notification sent!`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,13 @@ const jobs_config = {
|
||||
// worker processes of the same type.
|
||||
// (e.g. you can have two "main" workers)
|
||||
},
|
||||
|
||||
connector: {
|
||||
enabled: env('JOB_QUEUE_CONNECTOR', false),
|
||||
mount: env('JOB_QUEUE_CONNECTOR_MOUNT', '/job_queue_api'),
|
||||
secret: env('JOB_QUEUE_CONNECTOR_SECRET'),
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
module.exports = exports = jobs_config
|
||||
|
||||
@@ -33,3 +33,6 @@ SMTP_PORT="587"
|
||||
SMTP_USER="coreid@localhost.localdomain"
|
||||
SMTP_DEFAULT_SENDER="coreid@localhost.localdomain"
|
||||
SMTP_PASS="something super secure"
|
||||
|
||||
JOB_QUEUE_CONNECTOR=true
|
||||
JOB_QUEUE_CONNECTOR_SECRET=
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"flitter-forms": "^0.8.1",
|
||||
"flitter-gotify": "^0.1.0",
|
||||
"flitter-i18n": "^0.1.1",
|
||||
"flitter-jobs": "^0.1.2",
|
||||
"flitter-jobs": "^0.3.0",
|
||||
"flitter-less": "^0.5.3",
|
||||
"flitter-orm": "^0.4.0",
|
||||
"flitter-redis": "^0.1.1",
|
||||
@@ -33,7 +33,7 @@
|
||||
"ioredis": "^4.17.1",
|
||||
"is-absolute-url": "^3.0.3",
|
||||
"ldapjs": "^1.0.2",
|
||||
"libflitter": "^0.57.0",
|
||||
"libflitter": "^0.57.1",
|
||||
"moment": "^2.24.0",
|
||||
"mongodb": "^3.5.9",
|
||||
"nodemailer": "^6.4.6",
|
||||
|
||||
16
yarn.lock
16
yarn.lock
@@ -2148,10 +2148,10 @@ flitter-i18n@^0.1.1:
|
||||
ncp "^2.0.0"
|
||||
pluralize "^8.0.0"
|
||||
|
||||
flitter-jobs@^0.1.2:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/flitter-jobs/-/flitter-jobs-0.1.2.tgz#5536bb12be728b61f6e0940b6c18760e4f1b59d6"
|
||||
integrity sha512-bxJD3akDnoKPRyIXXy8ytlypGI8uj0Fjn2C8gIY2HFxZeFIBJo47MqQ9qZvVWFS28pS6aUY+0emOvTFkuG/2zA==
|
||||
flitter-jobs@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/flitter-jobs/-/flitter-jobs-0.3.0.tgz#c10fd45e4ab3c41c32ad4d8540b9b76547c20fbd"
|
||||
integrity sha512-uapjauWZCoZwc+3DuL0W1tY4LozSXTr3FqrKJEcL/Ri8diRYjZuT0+v+kiZBJ4YzThcjjXF+aYoFL09QlIG7Zw==
|
||||
dependencies:
|
||||
bullmq "^1.8.8"
|
||||
flitter-redis "^0.1.1"
|
||||
@@ -3235,10 +3235,10 @@ leven@^1.0.2:
|
||||
resolved "https://registry.yarnpkg.com/leven/-/leven-1.0.2.tgz#9144b6eebca5f1d0680169f1a6770dcea60b75c3"
|
||||
integrity sha1-kUS27ryl8dBoAWnxpncNzqYLdcM=
|
||||
|
||||
libflitter@^0.57.0:
|
||||
version "0.57.0"
|
||||
resolved "https://registry.yarnpkg.com/libflitter/-/libflitter-0.57.0.tgz#4383d188c4db5b36a5c684874b901ad964f1f721"
|
||||
integrity sha512-0yj9tXg5OW7C+sIdRm7ygw+kezaKaYrhvfONCKzqGn9gcUY7HGigALieSIaWuXnj7A+fn6e69gOyFnmwxwuZVQ==
|
||||
libflitter@^0.57.1:
|
||||
version "0.57.1"
|
||||
resolved "https://registry.yarnpkg.com/libflitter/-/libflitter-0.57.1.tgz#e605333a5e38cadac1203e4be8ea685c5520472b"
|
||||
integrity sha512-bEu02HZjcAp53A2xnE0hz/LVhkErvnqaKmlNOqvJJaGMjKClfVuqJlr9bFfWU84qXL9SaHWd06P3nxIVKTvFIw==
|
||||
dependencies:
|
||||
colors "^1.3.3"
|
||||
connect-mongodb-session "^2.2.0"
|
||||
|
||||
Reference in New Issue
Block a user