user presence event (#552)

This commit is contained in:
Connor Turland 2016-04-26 08:08:12 -04:00
parent 45adda93b1
commit c08868a5c1
5 changed files with 52 additions and 1 deletions

View file

@ -143,6 +143,9 @@ Metamaps.Visualize = {
self.mGraph.graph.empty() self.mGraph.graph.empty()
} }
if (self.type == 'ForceDirected' && Metamaps.Active.Mapper) $.post('/maps/' + Metamaps.Active.Map.id + '/events/user_presence')
function runAnimation () { function runAnimation () {
Metamaps.Loading.hide() Metamaps.Loading.hide()
// load JSON data, if it's not empty // load JSON data, if it's not empty

View file

@ -123,6 +123,9 @@ class MapsController < ApplicationController
if params[:event] == 'conversation' if params[:event] == 'conversation'
Events::ConversationStartedOnMap.publish!(map, current_user) Events::ConversationStartedOnMap.publish!(map, current_user)
valid_event = true valid_event = true
elsif params[:event] == 'user_presence'
Events::UserPresentOnMap.publish!(map, current_user)
valid_event = true
end end
respond_to do |format| respond_to do |format|

View file

@ -1,5 +1,5 @@
class Event < ActiveRecord::Base 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 #has_many :notifications, dependent: :destroy
belongs_to :eventable, polymorphic: true belongs_to :eventable, polymorphic: true

View file

@ -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

View file

@ -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