user presence event (#552)
This commit is contained in:
parent
45adda93b1
commit
c08868a5c1
5 changed files with 52 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
18
app/models/events/user_present_on_map.rb
Normal file
18
app/models/events/user_present_on_map.rb
Normal 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
|
27
app/models/webhooks/slack/user_present_on_map.rb
Normal file
27
app/models/webhooks/slack/user_present_on_map.rb
Normal 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
|
Loading…
Reference in a new issue