move glue code back to the initializer

This commit is contained in:
Benjamin Neff 2015-12-18 01:13:20 +01:00 committed by Dennis Schubert
parent f3e897ab43
commit 24f5244f76
2 changed files with 28 additions and 32 deletions

View file

@ -317,36 +317,6 @@ class Person < ActiveRecord::Base
self
end
def webfinger
DiasporaFederation::Discovery::WebFinger.new(
acct_uri: "acct:#{diaspora_handle}",
alias_url: AppConfig.url_to("/people/#{guid}"),
hcard_url: AppConfig.url_to(DiasporaFederation::Engine.routes.url_helpers.hcard_path(guid)),
seed_url: AppConfig.pod_uri,
profile_url: profile_url,
atom_url: atom_url,
salmon_url: receive_url,
guid: guid,
public_key: serialized_public_key
)
end
def hcard
DiasporaFederation::Discovery::HCard.new(
guid: guid,
nickname: username,
full_name: "#{profile.first_name} #{profile.last_name}".strip,
url: AppConfig.pod_uri,
photo_large_url: image_url,
photo_medium_url: image_url(:thumb_medium),
photo_small_url: image_url(:thumb_small),
public_key: serialized_public_key,
searchable: searchable,
first_name: profile.first_name,
last_name: profile.last_name
)
end
protected
def clean_url

View file

@ -8,12 +8,38 @@ DiasporaFederation.configure do |config|
config.define_callbacks do
on :fetch_person_for_webfinger do |handle|
person = Person.find_local_by_diaspora_handle(handle)
person.webfinger if person
if person
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)),
seed_url: AppConfig.pod_uri,
profile_url: person.profile_url,
atom_url: person.atom_url,
salmon_url: person.receive_url,
guid: person.guid,
public_key: person.serialized_public_key
)
end
end
on :fetch_person_for_hcard do |guid|
person = Person.find_local_by_guid(guid)
person.hcard if person
if person
DiasporaFederation::Discovery::HCard.new(
guid: person.guid,
nickname: person.username,
full_name: "#{person.profile.first_name} #{person.profile.last_name}".strip,
url: AppConfig.pod_uri,
photo_large_url: person.image_url,
photo_medium_url: person.image_url(:thumb_medium),
photo_small_url: person.image_url(:thumb_small),
public_key: person.serialized_public_key,
searchable: person.searchable,
first_name: person.profile.first_name,
last_name: person.profile.last_name
)
end
end
on :save_person_after_webfinger do |person|