Add support for token-based authorization in NTFY notifications and update project configuration

This commit is contained in:
Krisztián Szabolcsi 2026-01-10 17:52:54 +01:00
parent 2f8bce9a8a
commit 5a88e356e0
5 changed files with 17 additions and 4 deletions

1
.gitignore vendored
View File

@ -30,6 +30,7 @@ Thumbs.db
# project files
config.json
secret.json
# Keep .gitkeep files so empty folders can be tracked
!**/.gitkeep

View File

@ -58,7 +58,7 @@ publish: git_info
echo "Error: Nincs verzió szám"; \
exit 1; \
fi
#@sudo docker login $(DOCKER_REGISTRY)
@sudo docker login $(DOCKER_REGISTRY)
@sudo docker build \
--no-cache \
--label version=$(VERSION) \
@ -74,4 +74,7 @@ publish: git_info
--label org.opencontainers.image.source.hash=$(GIT_HASH) \
-t $(DOCKER_REGISTRY)/${OWNER}/$(NAME):$(VERSION) \
.
@sudo docker push $(DOCKER_REGISTRY)/$(NAME):$(VERSION)
@sudo docker push $(DOCKER_REGISTRY)/${OWNER}/$(NAME):$(VERSION)
create_secret:
cat "${ROOT_DIR}/src/config.json" | jq -c . > ./secret.json

View File

@ -1,2 +1,3 @@
NAME=imap_notification
DOCKER_REGISTRY=gitea.szabolcsi.dev
DOCKER_REGISTRY=gitea.szabolcsi.dev
OWNER=kriszcode

View File

@ -1,5 +1,6 @@
{
"lang": "en",
"token": "[optional] your ntfy token",
"accounts": [
{
"name": "Example",

View File

@ -56,6 +56,13 @@ async function sendNtfy(acc, subject, from, to) {
log.debug(`Sending ntfy notification for account [${acc.name}] with topic [${acc.topic}]`, messageBody);
const options = {}
if (config.token) {
options.headers = {
'Authorization': `Bearer ${config.token}`
}
}
await axios.post(`${NTFY_INTERNAL_URL}`, {
topic: acc.topic,
title: i18n.t('new_email_title'),
@ -63,7 +70,7 @@ async function sendNtfy(acc, subject, from, to) {
priority: 5,
tags: ['incoming_envelope'],
click: 'message://'
})
}, options);
} catch (err) {
log.error(i18n.t('ntfy_call_error'), err.message);