Skip to content

Commit 942ab52

Browse files
committed
Send application activity for channel creation as well as deletion.
1 parent b26b973 commit 942ab52

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

app/models/channel_observer.rb

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
class ChannelObserver < ActiveRecord::Observer
22
def after_destroy(channel)
3-
broadcast_data = {
4-
:event => "channel#delete",
3+
broadcast('delete', channel)
4+
end
5+
6+
def after_create(channel)
7+
broadcast('create', channel)
8+
end
9+
10+
private
11+
def broadcast(event, channel)
12+
data = {
13+
:event => "channel#" << event,
514
:entity => channel.attributes,
6-
:extra => {}
15+
:extra => {}
716
}
8-
9-
Kandan::Config.broadcaster.broadcast("/app/activities", broadcast_data)
17+
Kandan::Config.broadcaster.broadcast("/app/activities", data)
1018
end
1119
end

0 commit comments

Comments
 (0)