-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send application activity for channel creation as well as deletion.
- Loading branch information
Showing
1 changed file
with
13 additions
and
5 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 |
---|---|---|
@@ -1,11 +1,19 @@ | ||
class ChannelObserver < ActiveRecord::Observer | ||
def after_destroy(channel) | ||
broadcast_data = { | ||
:event => "channel#delete", | ||
broadcast('delete', channel) | ||
end | ||
|
||
def after_create(channel) | ||
broadcast('create', channel) | ||
end | ||
|
||
private | ||
def broadcast(event, channel) | ||
data = { | ||
:event => "channel#" << event, | ||
:entity => channel.attributes, | ||
:extra => {} | ||
:extra => {} | ||
} | ||
|
||
Kandan::Config.broadcaster.broadcast("/app/activities", broadcast_data) | ||
Kandan::Config.broadcaster.broadcast("/app/activities", data) | ||
end | ||
end |