rename callbacks
This commit is contained in:
parent
846483290f
commit
f4066f6105
7 changed files with 12 additions and 12 deletions
|
|
@ -43,7 +43,7 @@ DiasporaFederation.configure do |config|
|
||||||
config.server_uri = AppConfig.pod_uri
|
config.server_uri = AppConfig.pod_uri
|
||||||
|
|
||||||
config.define_callbacks do
|
config.define_callbacks do
|
||||||
on :person_webfinger_fetch do |diaspora_id|
|
on :fetch_person_for_webfinger do |diaspora_id|
|
||||||
person = Person.find_local_by_diaspora_id(diaspora_id)
|
person = Person.find_local_by_diaspora_id(diaspora_id)
|
||||||
if person
|
if person
|
||||||
DiasporaFederation::Discovery::WebFinger.new(
|
DiasporaFederation::Discovery::WebFinger.new(
|
||||||
|
|
@ -52,7 +52,7 @@ DiasporaFederation.configure do |config|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
on :person_hcard_fetch do |guid|
|
on :fetch_person_for_hcard do |guid|
|
||||||
# ...
|
# ...
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ module DiasporaFederation
|
||||||
#
|
#
|
||||||
# GET /hcard/users/:guid
|
# GET /hcard/users/:guid
|
||||||
def hcard
|
def hcard
|
||||||
person_hcard = DiasporaFederation.callbacks.trigger(:person_hcard_fetch, params[:guid])
|
person_hcard = DiasporaFederation.callbacks.trigger(:fetch_person_for_hcard, params[:guid])
|
||||||
|
|
||||||
if person_hcard.nil?
|
if person_hcard.nil?
|
||||||
render nothing: true, status: 404
|
render nothing: true, status: 404
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_person_webfinger(query)
|
def find_person_webfinger(query)
|
||||||
DiasporaFederation.callbacks.trigger(:person_webfinger_fetch, query.strip.downcase.sub("acct:", ""))
|
DiasporaFederation.callbacks.trigger(:fetch_person_for_webfinger, query.strip.downcase.sub("acct:", ""))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ module DiasporaFederation
|
||||||
extend Logging
|
extend Logging
|
||||||
|
|
||||||
@callbacks = Callbacks.new %i(
|
@callbacks = Callbacks.new %i(
|
||||||
person_webfinger_fetch
|
fetch_person_for_webfinger
|
||||||
person_hcard_fetch
|
fetch_person_for_hcard
|
||||||
)
|
)
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ module DiasporaFederation
|
||||||
expect(response).to be_not_found
|
expect(response).to be_not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls the person_hcard_fetch callback" do
|
it "calls the fetch_person_for_hcard callback" do
|
||||||
expect(DiasporaFederation.callbacks).to receive(:trigger)
|
expect(DiasporaFederation.callbacks).to receive(:trigger)
|
||||||
.with(:person_hcard_fetch, alice.guid)
|
.with(:fetch_person_for_hcard, alice.guid)
|
||||||
.and_call_original
|
.and_call_original
|
||||||
get :hcard, "guid" => alice.guid
|
get :hcard, "guid" => alice.guid
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ module DiasporaFederation
|
||||||
expect(response).to be_not_found
|
expect(response).to be_not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls the person_webfinger_fetch callback" do
|
it "calls the fetch_person_for_webfinger callback" do
|
||||||
expect(DiasporaFederation.callbacks).to receive(:trigger)
|
expect(DiasporaFederation.callbacks).to receive(:trigger)
|
||||||
.with(:person_webfinger_fetch, "alice@localhost:3000")
|
.with(:fetch_person_for_webfinger, "alice@localhost:3000")
|
||||||
.and_call_original
|
.and_call_original
|
||||||
get :legacy_webfinger, "q" => "acct:alice@localhost:3000"
|
get :legacy_webfinger, "q" => "acct:alice@localhost:3000"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ DiasporaFederation.configure do |config|
|
||||||
config.certificate_authorities = ca_file
|
config.certificate_authorities = ca_file
|
||||||
|
|
||||||
config.define_callbacks do
|
config.define_callbacks do
|
||||||
on :person_webfinger_fetch do |diaspora_id|
|
on :fetch_person_for_webfinger do |diaspora_id|
|
||||||
person = Person.find_by(diaspora_id: diaspora_id)
|
person = Person.find_by(diaspora_id: diaspora_id)
|
||||||
if person
|
if person
|
||||||
DiasporaFederation::Discovery::WebFinger.new(
|
DiasporaFederation::Discovery::WebFinger.new(
|
||||||
|
|
@ -33,7 +33,7 @@ DiasporaFederation.configure do |config|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
on :person_hcard_fetch do |guid|
|
on :fetch_person_for_hcard do |guid|
|
||||||
person = Person.find_by(guid: guid)
|
person = Person.find_by(guid: guid)
|
||||||
if person
|
if person
|
||||||
DiasporaFederation::Discovery::HCard.new(
|
DiasporaFederation::Discovery::HCard.new(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue