Sha256: 3b317cf44b84f02b6b4452f2047791464896026aac6662824b56e996c4db3036

Contents?: true

Size: 933 Bytes

Versions: 2

Compression:

Stored size: 933 Bytes

Contents

require "net/http"
require "uri"

module Social2social 
  module Models 
    module Shareable
      extend ActiveSupport::Concern
      
      included do
        after_create :init_feeds_to_hub
      end
      
      module InstanceMethods
        def init_feeds_to_hub
          publish_or_update_home_feed
          #TO-DO: add calls to other public feeds if any
        end
        
        def publish_or_update_home_feed
          t = Thread.new do
            hub = Social2social.hub 
            topic = Social2social.node_base_url+'/api/user/'+self.slug+'/home.atom'
            
            uri = URI.parse(hub)
            response = Net::HTTP::post_form(uri,{ 'hub.mode' => 'publish',
                                                  'hub.url'  => topic})
            #TO-DO: process 4XX look at: response.status                                      
          end
        end
            
      end

    end 
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
social2social-0.0.4 lib/social2social/models/shareable.rb
social2social-0.0.3 lib/social2social/models/shareable.rb