Commit 65b05634 authored by Benjamin Neff's avatar Benjamin Neff Committed by Jonne Haß
Browse files

update federation gem

parent a7bb6170
......@@ -12,7 +12,7 @@ gem "unicorn", "4.9.0", require: false
# Federation
gem "diaspora_federation-rails", "0.0.3"
gem "diaspora_federation-rails", "0.0.6"
# API and JSON
......
......@@ -152,10 +152,14 @@ GEM
eventmachine (>= 1.0.5, < 1.1)
http_parser.rb (~> 0.6)
nokogiri (~> 1.6)
diaspora_federation (0.0.3)
diaspora_federation (0.0.6)
faraday (~> 0.9.0)
faraday_middleware (~> 0.10.0)
nokogiri (~> 1.6, >= 1.6.6)
diaspora_federation-rails (0.0.3)
diaspora_federation (= 0.0.3)
typhoeus (~> 0.7.0)
valid (~> 1.0.0)
diaspora_federation-rails (0.0.6)
diaspora_federation (= 0.0.6)
rails (~> 4.2)
diff-lcs (1.2.5)
docile (1.1.5)
......@@ -731,6 +735,7 @@ GEM
raindrops (~> 0.7)
uuid (2.3.8)
macaddr (~> 1.0)
valid (1.0.0)
warden (1.2.3)
rack (>= 1.0)
webmock (1.21.0)
......@@ -764,7 +769,7 @@ DEPENDENCIES
devise-token_authenticatable (~> 0.4.0)
devise_lastseenable (= 0.0.6)
diaspora-vines (~> 0.1.28)
diaspora_federation-rails (= 0.0.3)
diaspora_federation-rails (= 0.0.6)
entypo-rails (= 2.2.3)
eye (= 0.7.pre)
facebox-rails (= 0.2.0)
......
......@@ -3,11 +3,13 @@ DiasporaFederation.configure do |config|
# the pod url
config.server_uri = AppConfig.pod_uri
config.certificate_authorities = AppConfig.environment.certificate_authorities.get
config.define_callbacks do
on :person_webfinger_fetch do |handle|
on :fetch_person_for_webfinger do |handle|
person = Person.find_local_by_diaspora_handle(handle)
if person
DiasporaFederation::WebFinger::WebFinger.new(
DiasporaFederation::Discovery::WebFinger.new(
acct_uri: "acct:#{person.diaspora_handle}",
alias_url: AppConfig.url_to("/people/#{person.guid}"),
hcard_url: AppConfig.url_to(DiasporaFederation::Engine.routes.url_helpers.hcard_path(person.guid)),
......@@ -21,10 +23,10 @@ DiasporaFederation.configure do |config|
end
end
on :person_hcard_fetch do |guid|
on :fetch_person_for_hcard do |guid|
person = Person.find_local_by_guid(guid)
if person
DiasporaFederation::WebFinger::HCard.new(
DiasporaFederation::Discovery::HCard.new(
guid: person.guid,
nickname: person.username,
full_name: "#{person.profile.first_name} #{person.profile.last_name}".strip,
......
require "spec_helper"
describe "diaspora federation callbacks" do
describe ":person_webfinger_fetch" do
describe ":fetch_person_for_webfinger" do
it "returns a WebFinger instance with the data from the person" do
person = alice.person
wf = DiasporaFederation.callbacks.trigger(:person_webfinger_fetch, alice.diaspora_handle)
wf = DiasporaFederation.callbacks.trigger(:fetch_person_for_webfinger, alice.diaspora_handle)
expect(wf.acct_uri).to eq("acct:#{person.diaspora_handle}")
expect(wf.alias_url).to eq(AppConfig.url_to("/people/#{person.guid}"))
expect(wf.hcard_url).to eq(AppConfig.url_to("/hcard/users/#{person.guid}"))
......@@ -17,15 +17,15 @@ describe "diaspora federation callbacks" do
end
it "returns nil if the person was not found" do
wf = DiasporaFederation.callbacks.trigger(:person_webfinger_fetch, "unknown@example.com")
wf = DiasporaFederation.callbacks.trigger(:fetch_person_for_webfinger, "unknown@example.com")
expect(wf).to be_nil
end
end
describe ":person_hcard_fetch" do
describe ":fetch_person_for_hcard" do
it "returns a HCard instance with the data from the person" do
person = alice.person
hcard = DiasporaFederation.callbacks.trigger(:person_hcard_fetch, alice.guid)
hcard = DiasporaFederation.callbacks.trigger(:fetch_person_for_hcard, alice.guid)
expect(hcard.guid).to eq(person.guid)
expect(hcard.nickname).to eq(person.username)
expect(hcard.full_name).to eq("#{person.profile.first_name} #{person.profile.last_name}")
......@@ -44,12 +44,12 @@ describe "diaspora federation callbacks" do
user.person.profile.last_name = nil
user.person.profile.save
hcard = DiasporaFederation.callbacks.trigger(:person_hcard_fetch, user.guid)
hcard = DiasporaFederation.callbacks.trigger(:fetch_person_for_hcard, user.guid)
expect(hcard.full_name).to eq(user.person.profile.first_name)
end
it "returns nil if the person was not found" do
hcard = DiasporaFederation.callbacks.trigger(:person_hcard_fetch, "1234567890abcdef")
hcard = DiasporaFederation.callbacks.trigger(:fetch_person_for_hcard, "1234567890abcdef")
expect(hcard).to be_nil
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment