Compare commits
2 Commits
b92ec64746
...
2f8bce9a8a
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f8bce9a8a | |||
| 30357418b5 |
30
Makefile
30
Makefile
@ -45,3 +45,33 @@ shell:
|
||||
|
||||
help:
|
||||
@printf "Usage:\n make build Build local docker image ($(IMAGE))\n make run Run image mounting project into $(WORKDIR) (port $(PORT))\n make stop Stop running container\n make shell Start a shell in a container with project mounted\n\nOverride variables: IMAGE, CONTAINER, WORKDIR, PORT, DOCKER_BUILD_ARGS, DOCKER_RUN_ARGS\n"
|
||||
|
||||
git_info:
|
||||
$(eval GIT_HASH = $(shell git rev-parse HEAD))
|
||||
$(eval GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD))
|
||||
|
||||
|
||||
publish: git_info
|
||||
$(eval VERSION = $(shell git describe --tags 2>/dev/null | grep -e '^[0-9]\.[0-9]*\.[0-9]'))
|
||||
@if [ -z "${VERSION}" ]; \
|
||||
then \
|
||||
echo "Error: Nincs verzió szám"; \
|
||||
exit 1; \
|
||||
fi
|
||||
#@sudo docker login $(DOCKER_REGISTRY)
|
||||
@sudo docker build \
|
||||
--no-cache \
|
||||
--label version=$(VERSION) \
|
||||
--label org.opencontainers.image.created=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--label org.opencontainers.image.authors="Krisztián Szabolcsi" \
|
||||
--label org.opencontainers.image.version=$(VERSION) \
|
||||
--label org.opencontainers.image.licences=MIT \
|
||||
--label org.opencontainers.image.source=https://${DOCKER_REGISTRY}/${OWNER}/${NAME} \
|
||||
--label org.opencontainers.image.revision=$(GIT_HASH) \
|
||||
--label org.opencontainers.image.vendor="Krisztián Szabolcsi" \
|
||||
--label org.opencontainers.image.description="IMAP email notification service using ntfy.sh" \
|
||||
--label org.opencontainers.image.source.branch=$(GIT_BRANCH) \
|
||||
--label org.opencontainers.image.source.hash=$(GIT_HASH) \
|
||||
-t $(DOCKER_REGISTRY)/${OWNER}/$(NAME):$(VERSION) \
|
||||
.
|
||||
@sudo docker push $(DOCKER_REGISTRY)/$(NAME):$(VERSION)
|
||||
@ -1 +1,2 @@
|
||||
NAME=imap_notification
|
||||
DOCKER_REGISTRY=gitea.szabolcsi.dev
|
||||
@ -6,6 +6,7 @@ const i18n = require('./i18n');
|
||||
const NTFY_INTERNAL_URL = process.env.NTFY_URL || 'https://ntfy.sh';
|
||||
const CONFIG_PATH = process.env.CONFIG_PATH || './config.json';
|
||||
const LOG_LEVEL = process.env.LOG_LEVEL || 'info';
|
||||
const IMAP_FLOW_LOG = process.env.IMAP_FLOW_LOG || false;
|
||||
let config;
|
||||
|
||||
const fromIcon = "\uD83D\uDC64"; // 👤
|
||||
@ -87,12 +88,13 @@ async function watchAccount(acc) {
|
||||
user: acc.user,
|
||||
pass: acc.pass
|
||||
},
|
||||
logger: (LOG_LEVEL === 'debug' ? log.debug : false)
|
||||
logger: IMAP_FLOW_LOG ? log.debug : false
|
||||
});
|
||||
|
||||
const run = async () => {
|
||||
try {
|
||||
await client.connect();
|
||||
|
||||
let lock = await client.getMailboxLock('INBOX');
|
||||
log.info(`[${acc.name}] ${i18n.t('watch_started')}`);
|
||||
|
||||
@ -100,6 +102,8 @@ async function watchAccount(acc) {
|
||||
// Fetch only envelope data (Subject, From)
|
||||
let message = await client.fetchOne(data.count, { envelope: true });
|
||||
|
||||
log.debug(`[${acc.name}] New message arrived:`, message);
|
||||
|
||||
const subject = message.envelope.subject || i18n.t('no_subject');
|
||||
const fromInfo = message.envelope.from[0];
|
||||
const fromDisplay = fromInfo.name ? fromInfo.name : fromInfo.address;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user