avoid the mapping gets deleted problem
This commit is contained in:
parent
a6bb688d0c
commit
839ff66bcf
9 changed files with 29 additions and 25 deletions
|
@ -2,10 +2,11 @@
|
|||
class Events::SynapseAddedToMap < Event
|
||||
# after_create :notify_users!
|
||||
|
||||
def self.publish!(mapping, user)
|
||||
def self.publish!(synapse, map, user, meta)
|
||||
create!(kind: 'synapse_added_to_map',
|
||||
eventable: mapping,
|
||||
map: mapping.map,
|
||||
user: user)
|
||||
eventable: synapse,
|
||||
map: map,
|
||||
user: user,
|
||||
meta: meta)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
class Events::SynapseRemovedFromMap < Event
|
||||
# after_create :notify_users!
|
||||
|
||||
def self.publish!(synapse, map, user)
|
||||
def self.publish!(synapse, map, user, meta)
|
||||
create!(kind: 'synapse_removed_from_map',
|
||||
eventable: synapse,
|
||||
map: map,
|
||||
user: user)
|
||||
user: user,
|
||||
meta: meta)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
class Events::TopicAddedToMap < Event
|
||||
# after_create :notify_users!
|
||||
|
||||
def self.publish!(mapping, user, meta)
|
||||
def self.publish!(topic, map, user, meta)
|
||||
create!(kind: 'topic_added_to_map',
|
||||
eventable: mapping,
|
||||
map: mapping.map,
|
||||
eventable: topic,
|
||||
map: map,
|
||||
user: user,
|
||||
meta: meta)
|
||||
end
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
class Events::TopicMovedOnMap < Event
|
||||
# after_create :notify_users!
|
||||
|
||||
def self.publish!(mapping, user, meta)
|
||||
def self.publish!(topic, map, user, meta)
|
||||
create!(kind: 'topic_moved_on_map',
|
||||
eventable: mapping,
|
||||
map: mapping.map,
|
||||
eventable: topic,
|
||||
map: map,
|
||||
user: user,
|
||||
meta: meta)
|
||||
end
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
class Events::TopicRemovedFromMap < Event
|
||||
# after_create :notify_users!
|
||||
|
||||
def self.publish!(topic, map, user)
|
||||
def self.publish!(topic, map, user, meta)
|
||||
create!(kind: 'topic_removed_from_map',
|
||||
eventable: topic,
|
||||
map: map,
|
||||
user: user)
|
||||
user: user,
|
||||
meta: meta)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,17 +30,17 @@ class Mapping < ApplicationRecord
|
|||
|
||||
def after_created
|
||||
if mappable_type == 'Topic'
|
||||
meta = {'x': xloc, 'y': yloc}
|
||||
Events::TopicAddedToMap.publish!(self, user, meta)
|
||||
meta = {'x': xloc, 'y': yloc, 'mapping_id': id}
|
||||
Events::TopicAddedToMap.publish!(mappable, map, user, meta)
|
||||
elsif mappable_type == 'Synapse'
|
||||
Events::SynapseAddedToMap.publish!(self, user)
|
||||
Events::SynapseAddedToMap.publish!(mappable, map, user, meta)
|
||||
end
|
||||
end
|
||||
|
||||
def after_updated
|
||||
if mappable_type == 'Topic' and (xloc_changed? or yloc_changed?)
|
||||
meta = {'x': xloc, 'y': yloc}
|
||||
Events::TopicMovedOnMap.publish!(self, user, meta)
|
||||
meta = {'x': xloc, 'y': yloc, 'mapping_id': id}
|
||||
Events::TopicMovedOnMap.publish!(mappable, map, user, meta)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -51,10 +51,11 @@ class Mapping < ApplicationRecord
|
|||
mappable.save
|
||||
end
|
||||
|
||||
meta = {'mapping_id': id}
|
||||
if mappable_type == 'Topic'
|
||||
Events::TopicRemovedFromMap.publish!(mappable, map, user)
|
||||
Events::TopicRemovedFromMap.publish!(mappable, map, user, meta)
|
||||
elsif mappable_type == 'Synapse'
|
||||
Events::SynapseRemovedFromMap.publish!(mappable, map, user)
|
||||
Events::SynapseRemovedFromMap.publish!(mappable, map, user, meta)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base
|
||||
def text
|
||||
connector = eventable.mappable.desc.empty? ? '->' : eventable.mappable.desc
|
||||
"\"*#{eventable.mappable.topic1.name}* #{connector} *#{eventable.mappable.topic2.name}*\" was added as a connection by *#{event.user.name}* to the map *#{view_map_on_metamaps}*"
|
||||
connector = eventable.desc.empty? ? '->' : eventable.desc
|
||||
"\"*#{eventable.topic1.name}* #{connector} *#{eventable.topic2.name}*\" was added as a connection by *#{event.user.name}* to the map *#{view_map_on_metamaps}*"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
class Webhooks::Slack::TopicAddedToMap < Webhooks::Slack::Base
|
||||
def text
|
||||
"*#{eventable.mappable.name}* was added by *#{event.user.name}* to the map *#{view_map_on_metamaps}*"
|
||||
"*#{eventable.name}* was added by *#{event.user.name}* to the map *#{view_map_on_metamaps}*"
|
||||
end
|
||||
# TODO: it would be sweet if it sends it with the metacode as the icon_url
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
class Webhooks::Slack::TopicMovedOnMap < Webhooks::Slack::Base
|
||||
def text
|
||||
"*#{eventable.mappable.name}* was moved by *#{event.user.name}* on the map *#{view_map_on_metamaps}*"
|
||||
"*#{eventable.name}* was moved by *#{event.user.name}* on the map *#{view_map_on_metamaps}*"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue