Class: RemoteSubject

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
SocialStream::Models::Subject
Defined in:
app/models/remote_subject.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#url_helperObject (readonly)

Returns the value of attribute url_helper.



6
7
8
# File 'app/models/remote_subject.rb', line 6

def url_helper
  @url_helper
end

Class Method Details

.find_or_create_by_webfinger_uri!(uri) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/remote_subject.rb', line 27

def find_or_create_by_webfinger_uri!(uri)
  if uri =~ /^https?:\/\//
    records = webfinger_alias(uri)

    # SQL scope is not reliable
    if records.present?
      return records.find{ |r| r.webfinger_aliases.include?(uri) }
    end

    # TODO: create by http uri?

    raise ::ActiveRecord::RecordNotFound
  end

  id = uri.dup

  if id =~ /^acct:/
    id.gsub!('acct:', '')
  end

  find_or_create_by_webfinger_id!(id)
end

Instance Method Details

#public_feed_urlObject

URL of the activity feed from this RemoteSubject



62
63
64
# File 'app/models/remote_subject.rb', line 62

def public_feed_url
  webfinger_info[:updates_from]
end

#refresh_webfinger!Object

Fetch the webfinger again



77
78
79
80
81
# File 'app/models/remote_subject.rb', line 77

def refresh_webfinger!
  fill_webfinger_info

  save!
end

#salmon_urlObject

URL of the Salmon endpoint for this RemoteSubject



67
68
69
# File 'app/models/remote_subject.rb', line 67

def salmon_url
  webfinger_info[:salmon]
end

#webfinger_aliasesObject

Webfinger Alias



72
73
74
# File 'app/models/remote_subject.rb', line 72

def webfinger_aliases
  webfinger_info[:aliases]
end

#webfinger_slugObject

Return the slug in the webfinger_id



52
53
54
# File 'app/models/remote_subject.rb', line 52

def webfinger_slug
  splitted_webfinger_id.first
end

#webfinger_urlObject

Return the origin url in the webfinger_id



57
58
59
# File 'app/models/remote_subject.rb', line 57

def webfinger_url
  splitted_webfinger_id.last
end