diff --git a/app/assets/javascripts/src/Metamaps.Visualize.js b/app/assets/javascripts/src/Metamaps.Visualize.js index 2b8231a8..2353cac5 100644 --- a/app/assets/javascripts/src/Metamaps.Visualize.js +++ b/app/assets/javascripts/src/Metamaps.Visualize.js @@ -143,6 +143,9 @@ Metamaps.Visualize = { self.mGraph.graph.empty() } + + if (self.type == 'ForceDirected' && Metamaps.Active.Mapper) $.post('/maps/' + Metamaps.Active.Map.id + '/events/user_presence') + function runAnimation () { Metamaps.Loading.hide() // load JSON data, if it's not empty diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index b605b5ad..e52b1833 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -123,6 +123,9 @@ class MapsController < ApplicationController if params[:event] == 'conversation' Events::ConversationStartedOnMap.publish!(map, current_user) valid_event = true + elsif params[:event] == 'user_presence' + Events::UserPresentOnMap.publish!(map, current_user) + valid_event = true end respond_to do |format| diff --git a/app/models/event.rb b/app/models/event.rb index 0ad350ea..66431b61 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,5 +1,5 @@ class Event < ActiveRecord::Base - KINDS = %w[conversation_started_on_map topic_added_to_map synapse_added_to_map] + KINDS = %w[user_present_on_map conversation_started_on_map topic_added_to_map synapse_added_to_map] #has_many :notifications, dependent: :destroy belongs_to :eventable, polymorphic: true diff --git a/app/models/events/user_present_on_map.rb b/app/models/events/user_present_on_map.rb new file mode 100644 index 00000000..e40df243 --- /dev/null +++ b/app/models/events/user_present_on_map.rb @@ -0,0 +1,18 @@ +class Events::UserPresentOnMap < Event + #after_create :notify_users! + + def self.publish!(map, user) + create!(kind: "user_present_on_map", + eventable: map, + map: map, + user: user) + end + + private + + #def notify_users! + # unless comment_vote.user == comment_vote.comment_user + # notify!(comment_vote.comment_user) + # end + #end +end diff --git a/app/models/webhooks/slack/user_present_on_map.rb b/app/models/webhooks/slack/user_present_on_map.rb new file mode 100644 index 00000000..b8d0fac5 --- /dev/null +++ b/app/models/webhooks/slack/user_present_on_map.rb @@ -0,0 +1,27 @@ +class Webhooks::Slack::UserPresentOnMap < Webhooks::Slack::Base + + def text + "Mapper *#{event.user.name}* has joined the map *#{event.map.name}*. #{view_map_on_metamaps('Map with them')}" + end + # todo: it would be sweet if it sends it with the metacode as the icon_url + + def attachment_fallback + "" #{}"*#{eventable.name}*\n#{eventable.description}\n" + end + + def attachment_title + "" #proposal_link(eventable) + end + + def attachment_text + "" # "#{eventable.description}\n" + end + + def attachment_fields + [{ + title: "nothing", + value: "nothing" + }] #[motion_vote_field] + end + +end