Module: SocialStream::Ostatus::Models::Actor

Extended by:
ActiveSupport::Concern
Defined in:
lib/social_stream/ostatus/models/actor.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#actor_key!Object

Fetch or create the associated ActorKey



41
42
43
44
# File 'lib/social_stream/ostatus/models/actor.rb', line 41

def actor_key!
  actor_key ||
    create_actor_key!
end

#magic_public_keyObject

MagicKey string from public key



65
66
67
# File 'lib/social_stream/ostatus/models/actor.rb', line 65

def magic_public_key
  Proudhon::MagicKey.to_s rsa_public_key
end

#publish_feedObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/social_stream/ostatus/models/actor.rb', line 69

def publish_feed
  return if subject_type == "RemoteSubject"

  # FIXME: Rails 4 queues
  Thread.new do
    uri = URI.parse(SocialStream::Ostatus.hub)
    topic = polymorphic_url [subject, :activities],
                            :format => :atom,
                            :host => SocialStream::Ostatus.activity_feed_host
    
    response = Net::HTTP::post_form uri, { 'hub.mode' => 'publish',
                                           'hub.url'  => topic }
    #TODO: process 4XX look at: response.status

    ActiveRecord::Base.connection.close
  end
end

#rsa_keyObject

OpenSSL::PKey::RSA key

The key is generated if it does not exist



49
50
51
# File 'lib/social_stream/ostatus/models/actor.rb', line 49

def rsa_key
  actor_key!.key
end

#rsa_key=(key) ⇒ Object

Set OpenSSL::PKey::RSA key



54
55
56
57
# File 'lib/social_stream/ostatus/models/actor.rb', line 54

def rsa_key= key
  k = actor_key || build_actor_key
  k.key = key
end

#rsa_public_keyObject

Public RSA instance of #rsa_key



60
61
62
# File 'lib/social_stream/ostatus/models/actor.rb', line 60

def rsa_public_key
  rsa_key.public_key
end

#webfinger_idObject

The Webfinger ID for this SocialStream::Ostatus::Models::Actor



31
32
33
# File 'lib/social_stream/ostatus/models/actor.rb', line 31

def webfinger_id
  "#{ slug }@#{ SocialStream::Ostatus.activity_feed_host }"
end

#webfinger_uriObject

The Webfinger URI for this SocialStream::Ostatus::Models::Actor



36
37
38
# File 'lib/social_stream/ostatus/models/actor.rb', line 36

def webfinger_uri
  "acct:#{ webfinger_id }"
end