-
Notifications
You must be signed in to change notification settings - Fork 900
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
Model for Async notification #10623
Model for Async notification #10623
Conversation
@isimluk Cannot apply the following label because they are not recognized: sql_migration |
@isimluk unrecognized command 'assig', ignoring... Accepted commands are: add_label, remove_label, rm_label, assign, set_milestone |
4e8c85c
to
f24608c
Compare
f24608c
to
646bed3
Compare
/cc @gtanzillo |
has_many :notification_recipients, :dependent => :delete_all | ||
has_many :recipients, :class_name => User, :through => :notification_recipients | ||
|
||
def self.emit(type, opts = {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be moved into initialize
with callbacks.
Each notification emitted by ManageIQ will have a type. That will make us more flexible, as we will have useful metadata for each notification. The application will emit many notification, it is expected that some users will want to customize what they receive. The notification type enables also that. Since we have the type in the database, we can later enable users to create their own notification types for their automate.
A notification has 3 optional attributes. - subject is something the notification is concerned with it can be a vm, provider, etc. - cause is something that initiated the operation, it can be a task, request, service order, etc. - initiator is user who initiated the process in question
M-to-N mapping between notification and users that can tell whether a particular user has already seen the notification that s/he received.
We will add much more notification types as we will need them.
Whenever you want to emit a new notification, you will write something like Notification.create!(:type => :vm_powered_off, :subject => vm) Various callers may or may not know the subject/cause/initiator attributes. That's why we make them optional.
646bed3
to
b8119e9
Compare
Improved based on feedback. Thanks @skateman. |
Checked commits isimluk/manageiq@9e99b6e~...b8119e9 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 |
👍 Looks great! |
Purpose
The asynchronous notification will notify user about started/running/finished tasks in the backend of ManageIQ. The POC for UI was in #6809.
Sample of the requirements was:
Entity Relationship Diagram
Note: This pr does not bring NotificationSubscription as this will be delivered in later stages.
@miq-bot add_label core, darga/no, sql migration, events, enhancement
@miq-bot assign @skateman