send public messages

This commit is contained in:
Benjamin Neff 2016-05-25 02:41:06 +02:00
parent 05bd61d4ff
commit 5f25135848
2 changed files with 19 additions and 4 deletions

View file

@ -8,7 +8,22 @@ module Diaspora
end
def deliver_to_remote(people)
# TODO
entity = Entities.build(object)
Workers::SendPublic.perform_async(sender.id, entity.to_s, target_urls(people), salmon_xml(entity))
end
private
def target_urls(people)
Pod.where(id: people.map(&:pod_id).uniq).map {|pod| pod.url_to("/receive/public") }
end
def salmon_xml(entity)
DiasporaFederation::Salmon::Slap.generate_xml(
sender.diaspora_handle,
sender.encryption_key,
entity
)
end
end
end

View file

@ -49,13 +49,13 @@ def generate_xml(entity, remote_user, recipient=nil)
if recipient
DiasporaFederation::Salmon::EncryptedSlap.prepare(
remote_user.diaspora_handle,
OpenSSL::PKey::RSA.new(remote_user.encryption_key),
remote_user.encryption_key,
entity
).generate_xml(OpenSSL::PKey::RSA.new(recipient.encryption_key))
).generate_xml(recipient.encryption_key)
else
DiasporaFederation::Salmon::Slap.generate_xml(
remote_user.diaspora_handle,
OpenSSL::PKey::RSA.new(remote_user.encryption_key),
remote_user.encryption_key,
entity
)
end