external_person.rb
1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# A pseudo profile is a person from a remote network
class ExternalPerson < ActiveRecord::Base
include Human
include ProfileEntity
validates_uniqueness_of :identifier, scope: :source
attr_accessible :source, :email, :created_at
def self.get_or_create(webfinger)
user = ExternalPerson.find_by(identifier: webfinger.identifier, source: webfinger.domain)
if user.nil?
user = ExternalPerson.create!(identifier: webfinger.identifier,
name: webfinger.name,
source: webfinger.domain,
email: webfinger.email,
created_at: webfinger.created_at
)
end
user
end
def url
"http://#{self.source}/#{self.identifier}"
end
alias :public_profile_url :url
def avatar
"http://#{self.source}/profile/#{self.identifier}/icon/"
end
def admin_url
"http://#{self.source}/myprofile/#{self.identifier}"
end
def profile_custom_icon(gravatar_default=nil)
self.avatar
end
def preferred_login_redirection
environment.redirection_after_login
end
def person?
true
end
def is_admin?(environment = nil)
false
end
def lat
nil
end
def lng
nil
end
def role_assignments
RoleAssignment.none
end
def favorite_enterprises
Enterprise.none
end
def memberships
Profile.none
end
def friendships
Profile.none
end
def follows?(profile)
false
end
def is_a_friend?(person)
false
end
def already_request_friendship?(person)
false
end
class ExternalPerson::Image
def initialize(path)
@path = path
end
def public_filename(size = nil)
URI.join(@path, size.to_s)
end
def content_type
'image/png'
end
end
def image
ExternalPerson::Image.new(path)
end
end