Skip to content

Feature/message email notifications queue#637

Open
Juergen-Coding wants to merge 2 commits intoNuSkooler:masterfrom
Juergen-Coding:feature/message-email-notifications-queue
Open

Feature/message email notifications queue#637
Juergen-Coding wants to merge 2 commits intoNuSkooler:masterfrom
Juergen-Coding:feature/message-email-notifications-queue

Conversation

@Juergen-Coding
Copy link
Copy Markdown

Summary

This PR adds email notifications for message areas, including a per-area user settings menu inside ENiGMA BBS.

Users can now configure notification preferences for selected message areas and receive email notifications for:

  • new posts in an area
  • replies to their own posts

The implementation uses a queue-based approach with scheduled processing, so notification delivery is decoupled from message posting.


What this PR adds

1. Queue-based email notification delivery

Instead of sending notification emails directly during message posting, this PR introduces a queue-based workflow:

  • notification jobs are created when qualifying messages are posted
  • jobs are stored in a dedicated notification queue
  • a worker processes queued jobs and sends emails
  • throttling is respected between outgoing emails

This keeps message posting responsive and makes delivery more robust.


2. Scheduled worker integration

The notification worker can be triggered through ENiGMA's event scheduler, which makes the solution suitable for both Linux and Windows environments without requiring a Linux-specific daemon/service model.

The worker:

  • polls at configurable intervals
  • avoids overlapping runs
  • processes the queue until idle
  • respects the configured delay between outgoing emails

3. Per-user notification settings menu

A new Notifications entry was added to the Message Menu.

Users can enter the notification settings screen and configure email behavior per eligible message area.

Current per-area options:

  • N = email on new posts
  • R = email on replies to the user's own posts

Only areas explicitly allowed by configuration are shown to the user.


4. Per-area policy support

This PR adds policy handling so that each area can independently allow:

  • new topic / new post notifications
  • reply-to-own-post notifications

This keeps the feature flexible and prevents notification options from appearing where the sysop does not want them.


5. Notification UI / ANSI integration

The notification settings screen now uses dedicated art files:

  • NTFMNU.ANS for the main screen
  • NTFPMPT.ANS for the prompt area

The dynamically generated area list is rendered inside the menu module, while the static layout remains in ANSI art.

The list was also visually improved so that:

  • area titles are highlighted
  • conference names are shown in a softer color
  • N: and R: labels are clearer
  • ON / OFF states are color-coded

Implementation details

Core behavior

Notification queueing is integrated into message posting/view logic and related notification policy checks.

New modules

This PR introduces notification-related modules for:

  • queue/database handling
  • policy decisions
  • queued delivery worker
  • notification settings menu

Menu integration

The Message Menu now includes an N command to enter notification settings.

Configuration

The worker interval and related behavior are configurable through the existing config structure.


Files included in this PR

New files

  • art/general/NTFMNU.ANS
  • art/general/NTFPMPT.ANS
  • config/menus/the_news_bbs-message_base.hjson
  • mods/notification_db.js
  • mods/notification_policy.js
  • mods/notification_queue_worker.js
  • mods/notification_settings_menu.js

Updated files

  • core/message.js
  • core/msg_area_post_fse.js
  • core/msg_area_view_fse.js
  • package.json
  • package-lock.json
  • yarn.lock

Behavior from a user perspective

A user can now:

  1. enter the Message Menu
  2. press N for Notifications
  3. view eligible message areas
  4. toggle:
    • 1N for new-post email notifications in area 1
    • 1R for reply email notifications in area 1
  5. quit back to the Message Menu

Testing performed

The feature was tested locally with real message posting and real email delivery scenarios.

Verified during testing:

  • queue entries are created correctly
  • scheduler-triggered worker runs process queued jobs
  • notification emails are sent according to the configured user preferences
  • reply notifications only trigger where expected
  • new-post notifications only trigger where expected
  • the Message Menu entry and notification settings screen work interactively
  • the message menu navigation keys still work after returning from the notifications screen

Notes

  • This PR intentionally focuses on the functional notification feature and its menu integration.
  • Personal/local theme experiments and unrelated ANSI/theme changes were intentionally left out of this PR.
  • The worker/scheduler approach was chosen to keep the feature cross-platform and to avoid relying on OS-specific service behavior.

Known limitations / future follow-up ideas

Possible follow-up improvements:

  • cleaner documentation for sysops
  • additional notification event types
  • improved wording/help text in the notification menu
  • further ANSI polish for the notification settings screen
  • optional batching or digest-style notifications

Why this approach

A queued notification model is safer and cleaner than sending email directly from the posting path.

It provides:

  • better responsiveness during posting
  • safer retry/throttling behavior
  • clearer separation between message creation and email delivery
Auswahl_214 Auswahl_189

@@ -0,0 +1,1071 @@
{
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is YOUR bbs file, not the menu template file

// Hide soft-deleted messages (we mark them by subject = "[DELETED]")
// Set filter.includeDeleted = true if you ever want to include them again.
if (true !== filter.includeDeleted) {
appendWhereClause(`IFNULL(m.subject, '') <> '[DELETED]'`, 'AND');
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't yet have soft deleted implemented, so this wouldn't work in the master branch

self.updateUserAndSystemStats(callback);
},
function queueNotifications(callback) {
fs.appendFileSync(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple issues here:

  1. We can't call sync code in the async context
  2. Hard coded paths, writing to a file like this, etc. isn't really the way to go. We have logging facilities. Queuing/etc., we have existing systems to look at (e.g. use the DB, or in memory if you're not worried about persistence)

const PROMPT_VIEW_ID = 2;
const MAX_RENDER_LINES = 10;

const C_RESET = '\x1b[0m';
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enigma uses a theming system, not hard coded colors/etc. For IDs, so on, see existing menu modules.

OpenAI should especially be able to follow the existing patterns. :)

@Juergen-Coding
Copy link
Copy Markdown
Author

Hi Nu,

Thank you for taking the time to review my pull request and pointing out where my implementation doesn't yet fully conform to existing ENiGMA patterns.

I tend to generate a lot of ideas quickly, but I also understand that for working on the upstream project, I need to study the project structure more closely and better adapt to the framework established in ENiGMA. That's exactly what I'm trying to do right now.

To structure this process, I've written a short Markdown document summarizing the rules and patterns that I believe can be derived from your comments, the master tree, and the ENiGMA documentation. It's not an official project document, but simply a working framework for me to make the feature cleaner and more upstream-friendly.

Would you please take a quick look at the Markdown file and let me know if my understanding is essentially correct?

My goal is to use this as a guideline for the next revision, ensuring my ideas remain within the bounds of what makes sense for ENiGMA and don't drift into overly localized or individualized solutions. ;)

enigma_upstream_starters.zip:
I've also started developing a small starter package for common contribution types, geared towards the upstream project.

The goal isn't to introduce additional abstraction, but rather to make the expected patterns of ENiGMA easier to understand in practice. Specifically, it could help contributors distinguish between local BBS-specific changes and changes suitable for the upstream project, and provide small reference structures for menu modules, module persistence, and planned internal tasks.

I hope this will reduce misunderstandings in future pull requests and facilitate the development of new features that adhere to the established ENiGMA structure from the outset.

Basically, it's for my understanding. ;)

Then next week I'll get to work adapting the new "features" to the Enigma BBS framework. I also need to familiarize myself with GitHut first. :)

Thanks & Cheers!

Have fun!

Jürgen
ENiGMA_BBS_Programming_Guide_Upstream_Changes.md
enigma_upstream_starters.zip

@tracker1
Copy link
Copy Markdown

Without looking, I would make sure that at least the following details were allowed to be set globally as well as to individual message boards.

  1. Email per notice
  2. Max of one summary email a day
  3. Max of one summary email per week (preferably with a day of the week selection)

This way you don't overload someone's inbox to the point they just ignore everything.

@tracker1
Copy link
Copy Markdown

On the coding guidelines, I would maybe suggest a separate pull request, expanding on the CONTRIBUTING.md document, which is where developer documentation tends to start, maybe with a ./docs/dev/ directory reference for expanded documentation.

Agents are pretty good at looking for at least README.md (which should reference CONTRIBUTING.md), or you can create a .gitignor'd YOURAGENT.md file that references CONTRIBUTING.md directly... Personally I try to make the documentation good for both people and agents when working with AI, assuming you are doing so.

I don't know how @NuSkooler would feel about a CLAUDE.md and/or AGENTS.md that simply contains @CONTRIBUTING.md as a pointer to the contributing documentation guidelines.

@NuSkooler
Copy link
Copy Markdown
Owner

Definitely need to beef up docs for AI consumption - CLAUDE.md, etc. to make things easier in our brave new world.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants