Skip to content

fix: resolve per-session config caching issue across plugins#38

Open
eabdalmufid wants to merge 1 commit into
rmyndharis:mainfrom
eabdalmufid:main
Open

fix: resolve per-session config caching issue across plugins#38
eabdalmufid wants to merge 1 commit into
rmyndharis:mainfrom
eabdalmufid:main

Conversation

@eabdalmufid

Copy link
Copy Markdown

Description

This PR fixes a bug where faq-bot, after-hours, and chat-flow plugins incorrectly cached their configuration statically at activation (onEnable/onConfigChange).

This static caching caused them to ignore dynamic per-session overrides (such as different rules or away messages for different WhatsApp numbers) managed by the OpenWA engine.

Changes Made

  • Refactored onMessage hooks in faq-bot, after-hours, and chat-flow.
  • Replaced this.config usage with a dynamic parseConfig(ctx.config) resolution per event, aligning them with the established pattern in http-action.
  • Implemented robust error handling: if a session's configuration contains invalid JSON, the plugin gracefully logs a warning via ctx.logger.warn and skips processing instead of falling back unexpectedly.
  • Successfully built dist/index.js artifacts for all affected plugins.

Testing

  • Verified multi-tenant per-session overrides now correctly apply at runtime.
  • Verified plugins gracefully handle invalid configurations without crashing the engine.

- Refactored faq-bot, after-hours, and chat-flow to parse configuration dynamically inside message hooks.

- Replaced global config caching with dynamic liveCfg resolution via ctx.config.

- Implemented consistent error handling to gracefully skip and warn on invalid configs.
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.

1 participant