Add support for token-based authorization in NTFY notifications and update project configuration
This commit is contained in:
parent
2f8bce9a8a
commit
5a88e356e0
1
.gitignore
vendored
1
.gitignore
vendored
@ -30,6 +30,7 @@ Thumbs.db
|
||||
|
||||
# project files
|
||||
config.json
|
||||
secret.json
|
||||
|
||||
# Keep .gitkeep files so empty folders can be tracked
|
||||
!**/.gitkeep
|
||||
7
Makefile
7
Makefile
@ -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
|
||||
@ -1,2 +1,3 @@
|
||||
NAME=imap_notification
|
||||
DOCKER_REGISTRY=gitea.szabolcsi.dev
|
||||
OWNER=kriszcode
|
||||
@ -1,5 +1,6 @@
|
||||
{
|
||||
"lang": "en",
|
||||
"token": "[optional] your ntfy token",
|
||||
"accounts": [
|
||||
{
|
||||
"name": "Example",
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user