Class: FacebookPublisher

Inherits:
Object
  • Object
show all
Extended by:
ActionView::Helpers::SanitizeHelper::ClassMethods
Includes:
ActionView::Helpers::SanitizeHelper, ActionView::Helpers::TextHelper
Defined in:
app/models/facebook_publisher.rb

Class Method Summary collapse

Class Method Details

.blog_post_created_hash(post) ⇒ Object


30
31
32
33
34
35
36
37
38
39
# File 'app/models/facebook_publisher.rb', line 30

def self.blog_post_created_hash(post)
  hash = {
    :method => "feed",
    :name => post.title,
    :description => strip_tags(post.post),
    :link => user_post_url(post.user, post, :host => default_host),
  }
  hash[:picture] = post.first_image_in_body unless post.first_image_in_body.nil?
  hash.to_json
end

.comment_created_hash(comment, url) ⇒ Object


21
22
23
24
25
26
27
28
# File 'app/models/facebook_publisher.rb', line 21

def self.comment_created_hash(comment, url)
  {
    :method => 'feed',
    :link => url,
    :name => "I left a comment on #{configatron.community_name}",
    :description => comment
  }.to_json
end

.connected(user) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/facebook_publisher.rb', line 8

def self.connected(user)
  text = "I joined #{configatron.community_name}."    
  if user.friends_ids.any?
    text += " There are #{pluralize user.friends_ids.size,'friends'} in my network."
  else
    text += " Want to join me?"
  end

  href = home_url

  user.graph.put_wall_post(text, :link => href, :name => configatron.community_name )
end

.default_hostObject


41
42
43
# File 'app/models/facebook_publisher.rb', line 41

def self.default_host
  configatron.app_host
end