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
|
# project files
|
||||||
config.json
|
config.json
|
||||||
|
secret.json
|
||||||
|
|
||||||
# Keep .gitkeep files so empty folders can be tracked
|
# Keep .gitkeep files so empty folders can be tracked
|
||||||
!**/.gitkeep
|
!**/.gitkeep
|
||||||
7
Makefile
7
Makefile
@ -58,7 +58,7 @@ publish: git_info
|
|||||||
echo "Error: Nincs verzió szám"; \
|
echo "Error: Nincs verzió szám"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
#@sudo docker login $(DOCKER_REGISTRY)
|
@sudo docker login $(DOCKER_REGISTRY)
|
||||||
@sudo docker build \
|
@sudo docker build \
|
||||||
--no-cache \
|
--no-cache \
|
||||||
--label version=$(VERSION) \
|
--label version=$(VERSION) \
|
||||||
@ -74,4 +74,7 @@ publish: git_info
|
|||||||
--label org.opencontainers.image.source.hash=$(GIT_HASH) \
|
--label org.opencontainers.image.source.hash=$(GIT_HASH) \
|
||||||
-t $(DOCKER_REGISTRY)/${OWNER}/$(NAME):$(VERSION) \
|
-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
|
NAME=imap_notification
|
||||||
DOCKER_REGISTRY=gitea.szabolcsi.dev
|
DOCKER_REGISTRY=gitea.szabolcsi.dev
|
||||||
|
OWNER=kriszcode
|
||||||
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"lang": "en",
|
"lang": "en",
|
||||||
|
"token": "[optional] your ntfy token",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"name": "Example",
|
"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);
|
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}`, {
|
await axios.post(`${NTFY_INTERNAL_URL}`, {
|
||||||
topic: acc.topic,
|
topic: acc.topic,
|
||||||
title: i18n.t('new_email_title'),
|
title: i18n.t('new_email_title'),
|
||||||
@ -63,7 +70,7 @@ async function sendNtfy(acc, subject, from, to) {
|
|||||||
priority: 5,
|
priority: 5,
|
||||||
tags: ['incoming_envelope'],
|
tags: ['incoming_envelope'],
|
||||||
click: 'message://'
|
click: 'message://'
|
||||||
})
|
}, options);
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.error(i18n.t('ntfy_call_error'), err.message);
|
log.error(i18n.t('ntfy_call_error'), err.message);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user