Files
hereconnect/services/message-delivery-method-web-push/README.md
T
ti 9c0ce14013
Deploy service message-delivery-method-web-push / service message-delivery-method-web-push (push) Successful in 57s
update readme
2024-12-03 19:38:02 +02:00

1.5 KiB

Web Push Notification Service

This service delivers web push notifications for chat messages and QR code events in HereConnect. It listens for changes in CouchDB and sends push notifications to users.

Features

  • Monitors CouchDB for new messages.
  • Sends push notifications to owners and guests.
  • Configurable notification settings.
  • Health server for monitoring.

Prerequisites

  • Node.js >= 14.x
  • CouchDB server
  • VAPID credentials

Installation

npm install

Running the Service

npm start

Usage

The service listens for changes in messages and sends notifications when a new message is created if the recipient has enabled push notifications.

Notifications are sent for:

  1. Messages from Guests: Sends to owners.
  2. Messages from Owners: Sends to guests if enabled.

Key Components

  • CouchDBChangesStream: Listens to CouchDB changes.
  • ServiceSeqTracker: Tracks sequence numbers to prevent missed messages.
  • Web Push Notifications: Uses web-push library.
  • Health Server: Monitors service status.

Notifications

New messages: Sends a push notification with title, body, and link to the chat.

Error Handling

Logs errors when sending notifications. Tracks sequence to avoid missed messages.

Graceful Shutdown

Handles SIGINT to stop CouchDB changes stream and clean up.

Health Monitoring

Includes a health server for checking service status.

References