Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

updated chats controller for iphone #39

Merged
merged 5 commits into from
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 15 deletions.
  1. +20 −15 app/controllers/chats_controller.rb
View
35 app/controllers/chats_controller.rb
@@ -17,27 +17,32 @@ def users
end
def send_data
+ if current_user.present?
+ user = current_user
+ body = params[:chat_input]
+ else
+ user = User.find(params[:id])
+ body = params[:body]
+ end
msg = sanitize(
auto_link(
auto_image(
- auto_mention(params[:chat_input])
+ auto_mention(body)
), :html => { :target => '_blank' }
), :tags => %w(a img mark), :attributes => %w(href src alt target)
)
- @post = current_user.posts.create!(:chat_input => msg)
- post_data = {
- :command => :broadcast,
- :body => msg,
- :name => current_user.name,
- :profile_image_url => current_user.profile_image_url,
- :twitter_login => current_user.login,
- :type => :to_channels_without_signature,
- :channels => 'groupon_go'
- }
- Pusher['groupon_go'].trigger!('new_post', post_data)
- #render :juggernaut => {:type => :send_to_channels, :channels => ['web']} do |page|
- # page.insert_html :top, 'chat_data', "<li>#{h params[:chat_input]}</li>"
- #end
+ if user.posts.create!(:chat_input => msg)
+ post_data = {
+ :command => :broadcast,
+ :body => msg,
+ :name => user.name,
+ :profile_image_url => user.profile_image_url,
+ :twitter_login => user.login,
+ :type => :to_channels_without_signature,
+ :channels => 'groupon_go'
+ }
+ Pusher['groupon_go'].trigger!('new_post', post_data)
+ end
render :nothing => true
end
Something went wrong with that request. Please try again.