-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17835 from skateman/generic-task-notifications
Create generic task notifications
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module NotificationMixin | ||
extend ActiveSupport::Concern | ||
|
||
def notify_task_start(message, user_id, subject = self) | ||
notify_task_emit(:generic_task_start, message, user_id, subject) | ||
end | ||
|
||
def notify_task_finish(message, user_id, subject = self) | ||
notify_task_emit(:generic_task_finish, message, user_id, subject) | ||
end | ||
|
||
def notify_task_fail(message, user_id, subject = self) | ||
notify_task_emit(:generic_task_fail, message, user_id, subject) | ||
end | ||
|
||
def notify_task_update(message, user_id, subject = self) | ||
notify_task_emit(:generic_task_update, message, user_id, subject) | ||
end | ||
|
||
private | ||
|
||
def notify_task_emit(type, message, user_id, subject) | ||
Notification.create(:type => type, :subject => subject, :user_id => user_id, :options => {:message => message}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters