1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-08-09 07:25:24 +02:00

Merge pull request #14 from ranshamay/email-support

Email support
This commit is contained in:
Ran Shamay 2023-11-21 14:11:28 +02:00 committed by GitHub
commit 8d98d7ec61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 4555 additions and 28427 deletions

View file

@ -1,57 +0,0 @@
# name: Build and publish release package
# on:
# release:
# types: [created]
# jobs:
# build-and-publish-release-package:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v3
# with:
# node-version: '18'
# cache: 'npm'
# - name: Workflow install pnpm
# run: npm install pnpm -g
# - name: Client install dependencies
# run: pnpm install
# - name: Server install dependencies
# run: pnpm install
# - name: Server include into dist
# run: mv server/ dist/
# - name: Client build production
# run: |
# npm run build
# working-directory: ./client
# - name: Client include into dist
# run: |
# mv build/index.html ../dist/views/index.ejs
# mv build/* ../dist/public/
# working-directory: ./client
# - name: Dist include README.md SECURITY.md LICENSE start.sh
# run: mv README.md SECURITY.md LICENSE start.sh dist/
# - name: Dist Remove node modules
# run: rm -R dist/node_modules
# - name: Dist create .zip file
# run: |
# mv dist/ planka/
# zip -r planka-prebuild-${{ github.event.release.tag_name }}.zip planka
# - name: Dist upload assets
# run: |
# gh release upload ${{ github.event.release.tag_name }} planka-prebuild-${{ github.event.release.tag_name }}.zip
# env:
# GH_TOKEN: ${{ github.token }}

14
.vscode/launch.json vendored Normal file
View 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

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,9 @@ services:
- DEFAULT_ADMIN_NAME=Demo Demo
- DEFAULT_ADMIN_USERNAME=demo
- MAIL_HOST=smtp.gmail.com
# related: https://github.com/knex/knex/issues/2354
# As knex does not pass query parameters from the connection string we
# have to use environment variables in order to pass the desired values, e.g.

2313
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -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",

View file

@ -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,
};

View 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;
},
};

View file

@ -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 || 25,
mailConnectorEmail: 'Planka <planka-noreplay@test.com>',
mailConnectorUser: process.env.MAIL_USER,
mailConnectorPass: process.env.MAIL_PASSWORD,
};

View file

@ -26,4 +26,5 @@ module.exports.policies = {
'access-tokens/create': true,
'access-tokens/exchange': true,
'appconfig/index': true,
'mail/index': true,
};

View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -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
View 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 };