add sender parameter to :receive_entity callback
This commit is contained in:
parent
215ff7902a
commit
fb60f83926
4 changed files with 20 additions and 20 deletions
|
|
@ -28,7 +28,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
def validate_and_receive
|
def validate_and_receive
|
||||||
validate
|
validate
|
||||||
DiasporaFederation.callbacks.trigger(:receive_entity, entity, recipient_id)
|
DiasporaFederation.callbacks.trigger(:receive_entity, entity, sender, recipient_id)
|
||||||
logger.info "successfully received #{entity} from person #{sender}#{" for #{recipient_id}" if recipient_id}"
|
logger.info "successfully received #{entity} from person #{sender}#{" for #{recipient_id}" if recipient_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
describe "#receive" do
|
describe "#receive" do
|
||||||
it "receives a private post" do
|
it "receives a private post" do
|
||||||
expect_callback(:receive_entity, post, recipient)
|
expect_callback(:receive_entity, post, post.author, recipient)
|
||||||
|
|
||||||
described_class.new(magic_env, recipient).receive
|
described_class.new(magic_env, recipient).receive
|
||||||
end
|
end
|
||||||
|
|
@ -32,7 +32,7 @@ module DiasporaFederation
|
||||||
it "receives a comment from the author" do
|
it "receives a comment from the author" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(comment, comment.author)
|
magic_env = Salmon::MagicEnvelope.new(comment, comment.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, comment, recipient)
|
expect_callback(:receive_entity, comment, comment.author, recipient)
|
||||||
|
|
||||||
described_class.new(magic_env, recipient).receive
|
described_class.new(magic_env, recipient).receive
|
||||||
end
|
end
|
||||||
|
|
@ -40,7 +40,7 @@ module DiasporaFederation
|
||||||
it "receives a comment from the parent author" do
|
it "receives a comment from the parent author" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(comment, comment.parent.author)
|
magic_env = Salmon::MagicEnvelope.new(comment, comment.parent.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, comment, recipient)
|
expect_callback(:receive_entity, comment, comment.parent.author, recipient)
|
||||||
|
|
||||||
described_class.new(magic_env, recipient).receive
|
described_class.new(magic_env, recipient).receive
|
||||||
end
|
end
|
||||||
|
|
@ -62,7 +62,7 @@ module DiasporaFederation
|
||||||
it "retracts a post from the author" do
|
it "retracts a post from the author" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.author)
|
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, retraction, recipient)
|
expect_callback(:receive_entity, retraction, retraction.author, recipient)
|
||||||
|
|
||||||
described_class.new(magic_env, recipient).receive
|
described_class.new(magic_env, recipient).receive
|
||||||
end
|
end
|
||||||
|
|
@ -89,7 +89,7 @@ module DiasporaFederation
|
||||||
it "retracts a comment from the author" do
|
it "retracts a comment from the author" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.author)
|
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, retraction, recipient)
|
expect_callback(:receive_entity, retraction, retraction.target.author, recipient)
|
||||||
|
|
||||||
described_class.new(magic_env, recipient).receive
|
described_class.new(magic_env, recipient).receive
|
||||||
end
|
end
|
||||||
|
|
@ -97,7 +97,7 @@ module DiasporaFederation
|
||||||
it "retracts a comment from the parent author" do
|
it "retracts a comment from the parent author" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.parent.author)
|
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.parent.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, retraction, recipient)
|
expect_callback(:receive_entity, retraction, retraction.target.parent.author, recipient)
|
||||||
|
|
||||||
described_class.new(magic_env, recipient).receive
|
described_class.new(magic_env, recipient).receive
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
describe "#receive" do
|
describe "#receive" do
|
||||||
it "receives a public post" do
|
it "receives a public post" do
|
||||||
expect_callback(:receive_entity, post, nil)
|
expect_callback(:receive_entity, post, post.author, nil)
|
||||||
|
|
||||||
described_class.new(magic_env).receive
|
described_class.new(magic_env).receive
|
||||||
end
|
end
|
||||||
|
|
@ -25,7 +25,7 @@ module DiasporaFederation
|
||||||
it "receives a comment from the author" do
|
it "receives a comment from the author" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(comment, comment.author)
|
magic_env = Salmon::MagicEnvelope.new(comment, comment.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, comment, nil)
|
expect_callback(:receive_entity, comment, comment.author, nil)
|
||||||
|
|
||||||
described_class.new(magic_env).receive
|
described_class.new(magic_env).receive
|
||||||
end
|
end
|
||||||
|
|
@ -33,7 +33,7 @@ module DiasporaFederation
|
||||||
it "receives a comment from the author parent" do
|
it "receives a comment from the author parent" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(comment, comment.parent.author)
|
magic_env = Salmon::MagicEnvelope.new(comment, comment.parent.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, comment, nil)
|
expect_callback(:receive_entity, comment, comment.parent.author, nil)
|
||||||
|
|
||||||
described_class.new(magic_env).receive
|
described_class.new(magic_env).receive
|
||||||
end
|
end
|
||||||
|
|
@ -53,9 +53,9 @@ module DiasporaFederation
|
||||||
let(:retraction) { FactoryGirl.build(:retraction_entity, target_type: "Post") }
|
let(:retraction) { FactoryGirl.build(:retraction_entity, target_type: "Post") }
|
||||||
|
|
||||||
it "retracts a post from the author" do
|
it "retracts a post from the author" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.author)
|
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, retraction, nil)
|
expect_callback(:receive_entity, retraction, retraction.author, nil)
|
||||||
|
|
||||||
described_class.new(magic_env).receive
|
described_class.new(magic_env).receive
|
||||||
end
|
end
|
||||||
|
|
@ -82,7 +82,7 @@ module DiasporaFederation
|
||||||
it "retracts a comment from the author" do
|
it "retracts a comment from the author" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.author)
|
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, retraction, nil)
|
expect_callback(:receive_entity, retraction, retraction.target.author, nil)
|
||||||
|
|
||||||
described_class.new(magic_env).receive
|
described_class.new(magic_env).receive
|
||||||
end
|
end
|
||||||
|
|
@ -90,7 +90,7 @@ module DiasporaFederation
|
||||||
it "retracts a comment from the parent author" do
|
it "retracts a comment from the parent author" do
|
||||||
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.parent.author)
|
magic_env = Salmon::MagicEnvelope.new(retraction, retraction.target.parent.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, retraction, nil)
|
expect_callback(:receive_entity, retraction, retraction.target.parent.author, nil)
|
||||||
|
|
||||||
described_class.new(magic_env).receive
|
described_class.new(magic_env).receive
|
||||||
end
|
end
|
||||||
|
|
@ -111,7 +111,7 @@ module DiasporaFederation
|
||||||
public_post = FactoryGirl.build(:status_message_entity, public: true)
|
public_post = FactoryGirl.build(:status_message_entity, public: true)
|
||||||
magic_env = Salmon::MagicEnvelope.new(public_post, public_post.author)
|
magic_env = Salmon::MagicEnvelope.new(public_post, public_post.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, public_post, nil)
|
expect_callback(:receive_entity, public_post, public_post.author, nil)
|
||||||
|
|
||||||
described_class.new(magic_env).receive
|
described_class.new(magic_env).receive
|
||||||
end
|
end
|
||||||
|
|
@ -129,7 +129,7 @@ module DiasporaFederation
|
||||||
profile = FactoryGirl.build(:profile_entity)
|
profile = FactoryGirl.build(:profile_entity)
|
||||||
magic_env = Salmon::MagicEnvelope.new(profile, profile.author)
|
magic_env = Salmon::MagicEnvelope.new(profile, profile.author)
|
||||||
|
|
||||||
expect_callback(:receive_entity, profile, nil)
|
expect_callback(:receive_entity, profile, profile.author, nil)
|
||||||
|
|
||||||
described_class.new(magic_env).receive
|
described_class.new(magic_env).receive
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
data = Salmon::MagicEnvelope.new(post, post.author).envelop(sender_key).to_xml
|
data = Salmon::MagicEnvelope.new(post, post.author).envelop(sender_key).to_xml
|
||||||
|
|
||||||
expect_callback(:receive_entity, kind_of(Entities::StatusMessage), nil) do |_, entity|
|
expect_callback(:receive_entity, kind_of(Entities::StatusMessage), post.author, nil) do |_, entity|
|
||||||
expect(entity.guid).to eq(post.guid)
|
expect(entity.guid).to eq(post.guid)
|
||||||
expect(entity.author).to eq(post.author)
|
expect(entity.author).to eq(post.author)
|
||||||
expect(entity.text).to eq(post.text)
|
expect(entity.text).to eq(post.text)
|
||||||
|
|
@ -26,7 +26,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
data = DiasporaFederation::Salmon::Slap.generate_xml(post.author, sender_key, post)
|
data = DiasporaFederation::Salmon::Slap.generate_xml(post.author, sender_key, post)
|
||||||
|
|
||||||
expect_callback(:receive_entity, kind_of(Entities::StatusMessage), nil) do |_, entity|
|
expect_callback(:receive_entity, kind_of(Entities::StatusMessage), post.author, nil) do |_, entity|
|
||||||
expect(entity.guid).to eq(post.guid)
|
expect(entity.guid).to eq(post.guid)
|
||||||
expect(entity.author).to eq(post.author)
|
expect(entity.author).to eq(post.author)
|
||||||
expect(entity.text).to eq(post.text)
|
expect(entity.text).to eq(post.text)
|
||||||
|
|
@ -52,7 +52,7 @@ module DiasporaFederation
|
||||||
magic_env = Salmon::MagicEnvelope.new(post, post.author).envelop(sender_key)
|
magic_env = Salmon::MagicEnvelope.new(post, post.author).envelop(sender_key)
|
||||||
data = Salmon::EncryptedMagicEnvelope.encrypt(magic_env, recipient_key.public_key)
|
data = Salmon::EncryptedMagicEnvelope.encrypt(magic_env, recipient_key.public_key)
|
||||||
|
|
||||||
expect_callback(:receive_entity, kind_of(Entities::StatusMessage), 1234) do |_, entity|
|
expect_callback(:receive_entity, kind_of(Entities::StatusMessage), post.author, 1234) do |_, entity|
|
||||||
expect(entity.guid).to eq(post.guid)
|
expect(entity.guid).to eq(post.guid)
|
||||||
expect(entity.author).to eq(post.author)
|
expect(entity.author).to eq(post.author)
|
||||||
expect(entity.text).to eq(post.text)
|
expect(entity.text).to eq(post.text)
|
||||||
|
|
@ -68,7 +68,7 @@ module DiasporaFederation
|
||||||
data = DiasporaFederation::Salmon::EncryptedSlap.prepare(post.author, sender_key, post)
|
data = DiasporaFederation::Salmon::EncryptedSlap.prepare(post.author, sender_key, post)
|
||||||
.generate_xml(recipient_key)
|
.generate_xml(recipient_key)
|
||||||
|
|
||||||
expect_callback(:receive_entity, kind_of(Entities::StatusMessage), 1234) do |_, entity|
|
expect_callback(:receive_entity, kind_of(Entities::StatusMessage), post.author, 1234) do |_, entity|
|
||||||
expect(entity.guid).to eq(post.guid)
|
expect(entity.guid).to eq(post.guid)
|
||||||
expect(entity.author).to eq(post.author)
|
expect(entity.author).to eq(post.author)
|
||||||
expect(entity.text).to eq(post.text)
|
expect(entity.text).to eq(post.text)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue