UnifiedPush: set clear default test titles/messages; improve compose health gating

This commit is contained in:
automation 2025-09-25 22:49:31 +00:00
parent 8db7d53337
commit 8c256e4e0f
2 changed files with 12 additions and 10 deletions

View file

@ -1,16 +1,19 @@
version: "3"
services: services:
server: server:
build: build:
context: . context: .
dockerfile: ./Dockerfile dockerfile: ./Dockerfile
target: server target: server
restart: unless-stopped
depends_on: depends_on:
- mongo mongo:
condition: service_healthy
environment: environment:
- NODE_DB_URI=mongodb://mongo/habitica?replicaSet=rs # this only needs to be adapted if using a separate database - NODE_DB_URI=mongodb://mongo/habitica?replicaSet=rs # adjust if you run an external Mongo database
- BASE_URL=http://127.0.0.1:8080 # change this to the URL under which your instance will be reachable - BASE_URL=http://127.0.0.1:3000 # change this to the URL under which your instance will be reachable
- INVITE_ONLY=false # change to `true` after registration of initial users, to restrict further registrations - INVITE_ONLY=false # change to `true` after registration of initial users, to restrict further registrations
- PUSH_CONFIGS_UNIFIEDPUSH_URL=${UP_BASE_URL:-} # optional: base URL for UnifiedPush distributor
- PUSH_CONFIGS_UNIFIEDPUSH_AUTHORIZATION=${UP_AUTH_HEADER:-} # optional: Authorization header for UnifiedPush
networks: networks:
- habitica - habitica
ports: ports:
@ -21,7 +24,7 @@ services:
hostname: mongo hostname: mongo
command: ["--replSet", "rs", "--bind_ip_all", "--port", "27017"] command: ["--replSet", "rs", "--bind_ip_all", "--port", "27017"]
healthcheck: healthcheck:
test: echo "try { rs.status() } catch (err) { rs.initiate({_id: 'rs', members: [{ _id: 0, host: 'mongo:27017' }]}) }" | mongosh --port 27017 --quiet test: ["CMD-SHELL", "echo \"try { rs.status() } catch (err) { rs.initiate({_id: 'rs', members: [{ _id: 0, host: 'mongo:27017' }]}) }\" | mongosh --quiet --port 27017"]
interval: 10s interval: 10s
timeout: 30s timeout: 30s
start_period: 0s start_period: 0s

View file

@ -87,11 +87,10 @@ api.sendUnifiedPushTest = {
throw new NotFound(res.t('pushDeviceNotFound')); throw new NotFound(res.t('pushDeviceNotFound'));
} }
const notificationTitle = req.body?.title // Use simple built-in defaults to avoid missing translation strings.
|| res.t('unifiedPushTestTitle', { defaultValue: 'Habitica UnifiedPush Test' }); const notificationTitle = req.body?.title || 'Test Successful';
const notificationMessage = req.body?.message const notificationMessage = req.body?.message || 'This is a test UnifiedPush notification from Habitica.';
|| res.t('unifiedPushTestMessage', { defaultValue: 'This is a test UnifiedPush notification from Habitica.' }); const successMessage = 'UnifiedPush test notification sent.';
const successMessage = res.t('unifiedPushTestSent', { defaultValue: 'UnifiedPush test notification sent.' });
const userForPush = user.toObject ? user.toObject() : { ...user }; const userForPush = user.toObject ? user.toObject() : { ...user };
userForPush._id = user._id; userForPush._id = user._id;