moved fb posting into the user model
This commit is contained in:
parent
a8bf082e35
commit
7ab2b00231
2 changed files with 8 additions and 4 deletions
|
|
@ -12,10 +12,7 @@ class StatusMessagesController < ApplicationController
|
|||
data = clean_hash params[:status_message]
|
||||
|
||||
if logged_into_fb? && params[:status_message][:public] == '1'
|
||||
id = 'me'
|
||||
type = 'feed'
|
||||
Rails.logger.info("Sending a message: #{params[:status_message][:message]} to Facebook")
|
||||
EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{params[:status_message][:message]}&access_token=#{@access_token}").post
|
||||
current_user.post_to_message_fb(params[:status_message][:message], @access_token)
|
||||
end
|
||||
|
||||
@status_message = current_user.post(:status_message, data)
|
||||
|
|
|
|||
|
|
@ -133,6 +133,13 @@ class User
|
|||
intitial_post(class_name, aspect_ids, options)
|
||||
end
|
||||
|
||||
def post_to_message_fb(message, access_token)
|
||||
id = 'me'
|
||||
type = 'feed'
|
||||
Rails.logger.info("Sending a message: #{message} to Facebook")
|
||||
EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{access_token}").post
|
||||
end
|
||||
|
||||
def intitial_post(class_name, aspect_ids, options = {})
|
||||
post = build_post(class_name, options)
|
||||
post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid)
|
||||
|
|
|
|||
Loading…
Reference in a new issue