add fetch_related_entity callback
This commit is contained in:
parent
1ee9d30ddb
commit
3ac21b585b
2 changed files with 17 additions and 0 deletions
|
|
@ -29,6 +29,7 @@ module DiasporaFederation
|
|||
fetch_author_public_key_by_entity_guid
|
||||
entity_author_is_local?
|
||||
fetch_entity_author_id_by_guid
|
||||
fetch_related_entity
|
||||
queue_public_receive
|
||||
queue_private_receive
|
||||
receive_entity
|
||||
|
|
@ -181,6 +182,12 @@ module DiasporaFederation
|
|||
# @param [String] guid of the entity
|
||||
# @return [String] Diaspora ID of the person
|
||||
#
|
||||
# fetch_related_entity
|
||||
# Fetches a related entity by a given guid
|
||||
# @param [String] entity_type (Post, Comment, Like, etc)
|
||||
# @param [String] guid of the entity
|
||||
# @return [DiasporaFederation::Entities::RelatedEntity] related entity
|
||||
#
|
||||
# queue_public_receive
|
||||
# Queue a public salmon xml to process in background
|
||||
# @param [String] data salmon slap xml or magic envelope xml
|
||||
|
|
|
|||
|
|
@ -90,6 +90,16 @@ DiasporaFederation.configure do |config|
|
|||
Entity.where(entity_type: entity_type, guid: guid).joins(:author).pluck(:diaspora_id).first
|
||||
end
|
||||
|
||||
on :fetch_related_entity do |entity_type, guid|
|
||||
entity = Entity.find_by(entity_type: entity_type, guid: guid)
|
||||
if entity
|
||||
DiasporaFederation::Entities::RelatedEntity.new(
|
||||
author: entity.author.diaspora_id,
|
||||
local: !entity.author.serialized_private_key.nil?
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
on :queue_public_receive do
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue