Skip to content

[Refactor] Notification plugins #9735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from

Conversation

SchrodingersGat
Copy link
Member

@SchrodingersGat SchrodingersGat commented Jun 3, 2025

Breaking Change

This PR represents a breaking change to any custom plugin which implements notification functionality. To continue to function, any such plugin must be reworked to follow the new approach:

  • Each custom notification method must be implemented as a separate plugin
  • Each custom notification method must inherit the NotificationMixin class
  • Refer to the 3x built-in notification plugins for examples

Details

This PR is a refactor of how notification methods are defined and collected.

Currently, it is a separate collection mechanism to plugins, and loading the notification methods is complex and somewhat "brittle" (compared to the plugin registry which has been optimized),

The intent here is to just make each notification method a plugin, which is then in line with our general concept of plugins. It also ensures that notification methods cannot be "collected" from plugins which are installed but not active (which is unfortunately the case currently).

TODO

  • Split built-in notification methods into separate plugins
  • Documentation for new built-in plugin types
  • Reimplement solution for per-user-per-plugin settings
  • Fix unit testing
  • Check that email notifications still work
  • Check that UI notification still work
  • API unit tests for new plugin-user-setting
  • Playwright tests for configuring plugin user settings

Related Issues

@SchrodingersGat SchrodingersGat added this to the 1.0.0 milestone Jun 3, 2025
@SchrodingersGat SchrodingersGat requested a review from matmair as a code owner June 3, 2025 23:58
Copy link

netlify bot commented Jun 3, 2025

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 54818f5
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/684ce5cdc9c81d0008f9042f
😎 Deploy Preview https://deploy-preview-9735--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 97 (no change from production)
Accessibility: 81 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@SchrodingersGat SchrodingersGat added plugin Plugin ecosystem refactor labels Jun 3, 2025
@SchrodingersGat SchrodingersGat marked this pull request as draft June 3, 2025 23:58
@SchrodingersGat SchrodingersGat added the breaking Indicates a major update or change which breaks compatibility label Jun 4, 2025
- Ensure plugin slug is correctly attached
- Consistent format
- Logic fixes
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 78.19905% with 46 lines in your changes missing coverage. Please review.

Project coverage is 85.25%. Comparing base (b02bc38) to head (54818f5).

Files with missing lines Patch % Lines
src/backend/InvenTree/plugin/api.py 52.17% 11 Missing ⚠️
...InvenTree/plugin/base/integration/SettingsMixin.py 58.33% 10 Missing ⚠️
src/backend/InvenTree/plugin/models.py 53.33% 7 Missing ⚠️
src/backend/InvenTree/common/notifications.py 78.57% 6 Missing ⚠️
...e/plugin/builtin/integration/core_notifications.py 92.45% 4 Missing ⚠️
src/backend/InvenTree/common/test_notifications.py 0.00% 3 Missing ⚠️
src/backend/InvenTree/InvenTree/permissions.py 66.66% 2 Missing ⚠️
src/backend/InvenTree/InvenTree/tasks.py 75.00% 1 Missing ⚠️
...nTree/plugin/base/integration/NotificationMixin.py 94.44% 1 Missing ⚠️
src/backend/InvenTree/plugin/base/label/label.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9735      +/-   ##
==========================================
- Coverage   86.30%   85.25%   -1.06%     
==========================================
  Files        1235     1238       +3     
  Lines       54258    54202      -56     
  Branches     2236     2236              
==========================================
- Hits        46828    46209     -619     
- Misses       6862     7425     +563     
  Partials      568      568              
Flag Coverage Δ
backend 86.71% <78.19%> (-1.50%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@matmair matmair left a comment

Choose a reason for hiding this comment

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

TBH there are so many lost / fundamentally changed mechanisms that I can not compare this to the current implementation as it just shares some entry points and names.
This means a new write of every even slightly complex notification method plugin and refactors for all plugins that trigger notifications.

@SchrodingersGat
Copy link
Member Author

@matmair fair comments - I'll see if I can adjust this to reduce the number of changes required

@SchrodingersGat SchrodingersGat added the bug Identifies a bug which needs to be addressed label Jun 9, 2025
- Allows plugins to define per-user settings
@SchrodingersGat SchrodingersGat added the migration Data or schema migrations label Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Indicates a major update or change which breaks compatibility bug Identifies a bug which needs to be addressed migration Data or schema migrations plugin Plugin ecosystem refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants