Skip to content

Commit

Permalink
Merge pull request #380 from Ravinou/develop
Browse files Browse the repository at this point in the history
release 2.4.3
  • Loading branch information
Ravinou authored Dec 26, 2024
2 parents 0d645fc + 66047df commit 8e9fa1e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 59 deletions.
54 changes: 30 additions & 24 deletions .github/workflows/docker-image-develop.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
name: Build and Push Docker Image for Develop Branch

on:
push:
branches:
- 'develop'
push:
branches:
- 'develop'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64 # linux/arm/v7 arm32 is not supported by node20 https://github.com/nodejs/docker-node/issues/1946
tags: borgwarehouse/borgwarehouse:develop
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update package.json version
run: |
COMMIT=$(git rev-parse --short HEAD)
echo "Current Commit: $COMMIT"
jq '.version = "develop-'$COMMIT'"' package.json > package.tmp.json
mv package.tmp.json package.json
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64 # linux/arm/v7 arm32 is not supported by node20 https://github.com/nodejs/docker-node/issues/1946
tags: borgwarehouse/borgwarehouse:develop
12 changes: 9 additions & 3 deletions Containers/UserSettings/EmailAlertSettings/EmailAlertSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,17 @@ export default function EmailAlertSettings() {
.then((response) => {
if (!response.ok) {
setTestIsLoading(false);
setError('Failed to send the notification.');
response
.json()
.then((data) => {
setError(data.message || 'Failed to send the notification.');
})
.catch(() => {
setError('Failed to send the notification.');
});
setTimeout(() => {
setError();
}, 4000);
}, 10000);
} else {
setTestIsLoading(false);
setInfo(true);
Expand All @@ -124,7 +131,6 @@ export default function EmailAlertSettings() {
})
.catch((error) => {
setTestIsLoading(false);
console.log(error);
setError('Send email failed. Contact your administrator.');
setTimeout(() => {
setError();
Expand Down
10 changes: 5 additions & 5 deletions helpers/functions/nodemailerSMTP.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import nodemailer from 'nodemailer';

export default function nodemailerSMTP() {
const transporter = nodemailer.createTransport({
port: process.env.MAIL_SMTP_PORT,
port: parseInt(process.env.MAIL_SMTP_PORT, 10),
host: process.env.MAIL_SMTP_HOST,
auth: {
user: process.env.MAIL_SMTP_LOGIN,
pass: process.env.MAIL_SMTP_PWD,
user: process.env.MAIL_SMTP_LOGIN || '',
pass: process.env.MAIL_SMTP_PWD || '',
},
tls: {
// do not fail on invalid certs >> allow self-signed or invalid TLS certificate
rejectUnauthorized: process.env.MAIL_REJECT_SELFSIGNED_TLS,
// false value allow self-signed or invalid TLS certificate
rejectUnauthorized: process.env.MAIL_REJECT_SELFSIGNED_TLS === 'false' ? false : true,
},
});
return transporter;
Expand Down
30 changes: 7 additions & 23 deletions pages/api/account/sendTestEmail.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
//Lib
import { authOptions } from '../auth/[...nextauth]';
import { getServerSession } from 'next-auth/next';
import nodemailerSMTP from '../../../helpers/functions/nodemailerSMTP';
import emailTest from '../../../helpers/templates/emailTest';

export default async function handler(req, res) {
if (req.method == 'POST') {
//Verify that the user is logged in.
const session = await getServerSession(req, res, authOptions);
if (!session) {
res.status(401).json({ message: 'You must be logged in.' });
return;
return res.status(401).json({ message: 'You must be logged in.' });
}

//Create the SMTP Transporter
const transporter = nodemailerSMTP();

//Mail options
const mailData = emailTest(session.user.email, session.user.name);

//Send mail
try {
transporter.sendMail(mailData, function (err, info) {
if (err) {
console.log(err);
res.status(400).json({
message: 'An error occured while sending the email : ' + err,
});
return;
} else {
console.log(info);
res.status(200).json({
message: 'Mail successfully sent.',
});
return;
}
const info = await transporter.sendMail(mailData);
console.log(info);
return res.status(200).json({
message: 'Mail successfully sent',
});
} catch (err) {
console.log(err);
res.status(500).json({
status: 500,
message: 'API error, contact the administrator.',
return res.status(400).json({
message: 'An error occurred while sending the email: ' + err,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion pages/api/repo/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default async function handler(req, res) {

await saveRepoList(newRepoList);

return res.status(200).json({ message: 'success' });
return res.status(200).json({ id: newRepo.id, repositoryName: newRepo.repositoryName });
} catch (error) {
handleError(error, res);
}
Expand Down
6 changes: 3 additions & 3 deletions pages/api/repo/id/[slug]/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ export default async function handler(req, res) {
if (indexToDelete !== -1) {
repoList.splice(indexToDelete, 1);
} else {
console.log('The index to delete does not existe (-1)');
res.status(500).json({
message: 'API error, contact the administrator',
console.log('The index to delete does not exist');
res.status(400).json({
message: 'This repository does not exist',
});
return;
}
Expand Down

0 comments on commit 8e9fa1e

Please sign in to comment.