From 6c3c9f8c7a47626697ecc3179accaaea3ac090dc Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sat, 11 Feb 2017 00:14:00 -0500 Subject: [PATCH] Update mapping.rb --- app/models/mapping.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/models/mapping.rb b/app/models/mapping.rb index a1ebdaf5..f8430bde 100644 --- a/app/models/mapping.rb +++ b/app/models/mapping.rb @@ -30,6 +30,8 @@ class Mapping < ApplicationRecord def after_created if mappable_type == 'Topic' ActionCable.server.broadcast 'map_' + map.id.to_s, type: 'topicAdded', topic: mappable.filtered, mapping_id: id + meta = { 'x': xloc, 'y': yloc, 'mapping_id': id } + Events::TopicAddedToMap.publish!(mappable, map, user, meta) elsif mappable_type == 'Synapse' ActionCable.server.broadcast( 'map_' + map.id.to_s, @@ -39,17 +41,12 @@ class Mapping < ApplicationRecord topic2: mappable.topic2.filtered, mapping_id: id ) + Events::SynapseAddedToMap.publish!(mappable, map, user, nil) end end def after_created_async FollowService.follow(map, user, 'contributed') - if mappable_type == 'Topic' - meta = { 'x': xloc, 'y': yloc, 'mapping_id': id } - Events::TopicAddedToMap.publish!(mappable, map, user, meta) - elsif mappable_type == 'Synapse' - Events::SynapseAddedToMap.publish!(mappable, map, user, nil) - end end handle_asynchronously :after_created_async