mirror of
https://github.com/plankanban/planka.git
synced 2025-08-09 23:45:31 +02:00
support mail
This commit is contained in:
parent
8d2b66913c
commit
d161f259ff
12 changed files with 4552 additions and 28370 deletions
14
.vscode/launch.json
vendored
Normal file
14
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm start",
|
||||
"name": "Run npm start",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
24191
client/package-lock.json
generated
24191
client/package-lock.json
generated
File diff suppressed because it is too large
Load diff
2313
package-lock.json
generated
2313
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -58,7 +58,10 @@
|
|||
"dependencies": {
|
||||
"concurrently": "^7.6.0",
|
||||
"husky": "^8.0.2",
|
||||
"lint-staged": "^13.0.3"
|
||||
"lint-staged": "^13.0.3",
|
||||
"nodemailer": "^6.9.7",
|
||||
"nodemailer-direct-transport": "^3.3.2",
|
||||
"nodemailer-smtp-transport": "^2.7.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.28.0",
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const { sendUserEmails } = require('../../../utils/mail');
|
||||
|
||||
const Errors = {
|
||||
NOT_ENOUGH_RIGHTS: {
|
||||
notEnoughRights: 'Not enough rights',
|
||||
|
@ -77,7 +79,7 @@ module.exports = {
|
|||
request: this.req,
|
||||
})
|
||||
.intercept('userAlreadyCardMember', () => Errors.USER_ALREADY_CARD_MEMBER);
|
||||
|
||||
await sendUserEmails({ to: [inputs.userId], subject: 'b', text: 'c' });
|
||||
return {
|
||||
item: cardMembership,
|
||||
};
|
||||
|
|
26
server/api/controllers/mail/index.js
Normal file
26
server/api/controllers/mail/index.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
const { sendEmail } = require('../../../utils/mail');
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
to: {
|
||||
type: 'json',
|
||||
required: false,
|
||||
},
|
||||
subject: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
},
|
||||
text: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
},
|
||||
cc: {
|
||||
type: 'json',
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
async fn({ to = [], subject = '', text = '', cc = [] }) {
|
||||
const mailResult = await sendEmail({ to, subject, text, cc });
|
||||
return mailResult;
|
||||
},
|
||||
};
|
|
@ -42,4 +42,10 @@ module.exports.custom = {
|
|||
oidcSkipUserInfo: process.env.OIDC_SKIP_USER_INFO === 'true',
|
||||
|
||||
defaultAdminEmail: process.env.DEFAULT_ADMIN_EMAIL,
|
||||
|
||||
mailConnectorHost: process.env.MAIL_HOST,
|
||||
mailConnectorPort: process.env.MAIL_PORT || 587,
|
||||
mailConnectorEmail: 'Planka <planka-noreplay@test.com>',
|
||||
mailConnectorUser: process.env.MAIL_USER,
|
||||
mailConnectorPass: process.env.MAIL_PASSWORD,
|
||||
};
|
||||
|
|
|
@ -26,4 +26,5 @@ module.exports.policies = {
|
|||
'access-tokens/create': true,
|
||||
'access-tokens/exchange': true,
|
||||
'appconfig/index': true,
|
||||
'mail/index': true,
|
||||
};
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
module.exports.routes = {
|
||||
'GET /api/appconfig': 'appconfig/index',
|
||||
|
||||
'POST /api/mail': 'mail/index',
|
||||
|
||||
'POST /api/access-tokens': 'access-tokens/create',
|
||||
'POST /api/access-tokens/exchange': 'access-tokens/exchange',
|
||||
'DELETE /api/access-tokens/me': 'access-tokens/delete',
|
||||
|
|
6323
server/package-lock.json
generated
6323
server/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -37,6 +37,7 @@
|
|||
"lodash": "^4.17.21",
|
||||
"moment": "^2.29.4",
|
||||
"move-file": "^2.1.0",
|
||||
"nodemailer": "^6.9.7",
|
||||
"openid-client": "^5.4.3",
|
||||
"rimraf": "^3.0.2",
|
||||
"sails": "^1.5.3",
|
||||
|
|
36
server/utils/mail.js
Normal file
36
server/utils/mail.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
const nodemailer = require('nodemailer');
|
||||
|
||||
const mailerConfig = {
|
||||
host: sails.config.custom.mailConnectorHost,
|
||||
port: sails.config.custom.mailConnectorPort,
|
||||
};
|
||||
if (sails.config.custom.mailConnectorUser) {
|
||||
Object.assign(mailerConfig, {
|
||||
auth: {
|
||||
user: sails.config.custom.mailConnectorUser,
|
||||
pass: sails.config.custom.mailConnectorPass,
|
||||
},
|
||||
});
|
||||
}
|
||||
const transport = nodemailer.createTransport(mailerConfig);
|
||||
|
||||
const sendEmail = async ({ to, subject, text, cc }) => {
|
||||
try {
|
||||
await transport.sendMail({
|
||||
from: sails.config.custom.mailConnectorEmail,
|
||||
to,
|
||||
cc,
|
||||
subject,
|
||||
html: text,
|
||||
});
|
||||
} catch (e) {
|
||||
sails.log(e);
|
||||
}
|
||||
};
|
||||
|
||||
const sendUserEmails = async ({ ids, subject, text, cc }) => {
|
||||
const users = await sails.helpers.users.getMany(ids);
|
||||
return sendEmail({ to: users.map((u) => u.email), subject, text, cc });
|
||||
};
|
||||
|
||||
module.exports = { sendEmail, sendUserEmails };
|
Loading…
Add table
Add a link
Reference in a new issue