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
|
# File 'app/controllers/pshb_controller.rb', line 3
def callback
if params['hub.mode']=='subscribe'
render :text => params['hub.challenge'], :status => 200
return
end
if params['hub.mode']=='unsubscribe'
render :text => params['hub.challenge'], :status => 200
return
end
doc = Nokogiri::XML(request.body.read)
origin = doc.xpath("//xmlns:link[@rel='self']").first['href'].split('/')
webfinger_slug = origin[5]+"@"+origin[2]
activity_texts = doc.xpath("//xmlns:content")
activity_texts.each do |activity_text|
r_user = RemoteSubject.find_by_webfinger_slug(webfinger_slug)
if r_user != nil
Post.create!(:text => activity_text.content, :_activity_tie_id => r_user.public_tie)
end
end
end
|