Skip to content

Commit

Permalink
Send application activity for channel creation as well as deletion.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjtko committed Mar 2, 2013
1 parent b26b973 commit 942ab52
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/models/channel_observer.rb
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

0 comments on commit 942ab52

Please sign in to comment.