DG MS; renamed a file; fixed the build
This commit is contained in:
parent
70deed01e1
commit
ba8e50e34c
10 changed files with 26 additions and 26 deletions
|
|
@ -55,6 +55,7 @@ class Conversation < ActiveRecord::Base
|
||||||
self.participants.each do |participant|
|
self.participants.each do |participant|
|
||||||
ConversationVisibility.find_or_create_by_conversation_id_and_person_id(cnv.id, participant.id)
|
ConversationVisibility.find_or_create_by_conversation_id_and_person_id(cnv.id, participant.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.messages.each do |msg|
|
self.messages.each do |msg|
|
||||||
msg.conversation_id = cnv.id
|
msg.conversation_id = cnv.id
|
||||||
received_msg = msg.receive(user, person)
|
received_msg = msg.receive(user, person)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
require File.join(Rails.root, 'lib/postzord/receiver/private')
|
require File.join(Rails.root, 'lib/postzord/receiver/private')
|
||||||
require File.join(Rails.root, 'lib/postzord/receiver/local_post_batch')
|
require File.join(Rails.root, 'lib/postzord/receiver/local_batch')
|
||||||
|
|
||||||
module Jobs
|
module Jobs
|
||||||
class ReceiveLocalBatch < Base
|
class ReceiveLocalBatch < Base
|
||||||
|
|
@ -12,7 +12,7 @@ module Jobs
|
||||||
|
|
||||||
def self.perform(object_class_string, object_id, recipient_user_ids)
|
def self.perform(object_class_string, object_id, recipient_user_ids)
|
||||||
object = object_class_string.constantize.find(object_id)
|
object = object_class_string.constantize.find(object_id)
|
||||||
receiver = Postzord::Receiver::LocalPostBatch.new(object, recipient_user_ids)
|
receiver = Postzord::Receiver::LocalBatch.new(object, recipient_user_ids)
|
||||||
receiver.perform!
|
receiver.perform!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
module Job
|
module Jobs
|
||||||
class PublishToHub < Base
|
class PublishToHub < Base
|
||||||
@queue = :http_service
|
@queue = :http_service
|
||||||
def self.perform(sender_public_url)
|
def self.perform(sender_public_url)
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ class Postzord::Dispatcher
|
||||||
# @param people [Array<Person>] Recipients of the post
|
# @param people [Array<Person>] Recipients of the post
|
||||||
def deliver_to_local(people)
|
def deliver_to_local(people)
|
||||||
return if people.blank? || @object.is_a?(Profile)
|
return if people.blank? || @object.is_a?(Profile)
|
||||||
if @object.respond_to?(:persisted?)
|
if @object.respond_to?(:persisted?) && !@object.is_a?(Conversation)
|
||||||
batch_deliver_to_local(people)
|
batch_deliver_to_local(people)
|
||||||
else
|
else
|
||||||
people.each do |person|
|
people.each do |person|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module Postzord
|
module Postzord
|
||||||
module Receiver
|
module Receiver
|
||||||
class LocalPostBatch
|
class LocalBatch
|
||||||
attr_reader :object, :recipient_user_ids, :users
|
attr_reader :object, :recipient_user_ids, :users
|
||||||
|
|
||||||
def initialize(object, recipient_user_ids)
|
def initialize(object, recipient_user_ids)
|
||||||
|
|
@ -13,7 +13,7 @@ module Postzord
|
||||||
if @object.respond_to?(:relayable?)
|
if @object.respond_to?(:relayable?)
|
||||||
receive_relayable
|
receive_relayable
|
||||||
else
|
else
|
||||||
create_visibilities
|
create_post_visibilities
|
||||||
end
|
end
|
||||||
notify_mentioned_users if @object.respond_to?(:mentions)
|
notify_mentioned_users if @object.respond_to?(:mentions)
|
||||||
|
|
||||||
|
|
@ -31,10 +31,10 @@ module Postzord
|
||||||
@object
|
@object
|
||||||
end
|
end
|
||||||
|
|
||||||
# Batch import visibilities for the recipients of the given @object
|
# Batch import post visibilities for the recipients of the given @object
|
||||||
# @note performs a bulk insert into mySQL
|
# @note performs a bulk insert into mySQL
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def create_visibilities
|
def create_post_visibilities
|
||||||
contacts = Contact.where(:user_id => @recipient_user_ids, :person_id => @object.author_id)
|
contacts = Contact.where(:user_id => @recipient_user_ids, :person_id => @object.author_id)
|
||||||
PostVisibility.batch_import(contacts, object)
|
PostVisibility.batch_import(contacts, object)
|
||||||
end
|
end
|
||||||
|
|
@ -49,7 +49,6 @@ module Postzord
|
||||||
obj
|
obj
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def salmon
|
def salmon
|
||||||
@salmon ||= Salmon::EncryptedSlap.from_xml(@salmon_xml, @user)
|
@salmon ||= Salmon::EncryptedSlap.from_xml(@salmon_xml, @user)
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ module Postzord
|
||||||
@object.receive(@object.parent.author.owner, @author)
|
@object.receive(@object.parent.author.owner, @author)
|
||||||
end
|
end
|
||||||
# notify everyone who can see the parent object
|
# notify everyone who can see the parent object
|
||||||
receiver = Postzord::Receiver::LocalPostBatch.new(@object, self.recipient_user_ids)
|
receiver = Postzord::Receiver::LocalBatch.new(@object, self.recipient_user_ids)
|
||||||
receiver.notify_users
|
receiver.notify_users
|
||||||
@object
|
@object
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require File.join(Rails.root, 'lib','postzord', 'receiver', 'local_post_batch')
|
require File.join(Rails.root, 'lib','postzord', 'receiver', 'local_batch')
|
||||||
|
|
||||||
describe Postzord::Receiver::LocalPostBatch do
|
describe Postzord::Receiver::LocalBatch do
|
||||||
before do
|
before do
|
||||||
@object = Factory(:status_message, :author => alice.person)
|
@object = Factory(:status_message, :author => alice.person)
|
||||||
@ids = [bob.id]
|
@ids = [bob.id]
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:receiver) { Postzord::Receiver::LocalPostBatch.new(@object, @ids) }
|
let(:receiver) { Postzord::Receiver::LocalBatch.new(@object, @ids) }
|
||||||
|
|
||||||
describe '.initialize' do
|
describe '.initialize' do
|
||||||
it 'sets @post, @recipient_user_ids, and @user' do
|
it 'sets @post, @recipient_user_ids, and @user' do
|
||||||
|
|
@ -18,8 +18,8 @@ describe Postzord::Receiver::LocalPostBatch do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#perform!' do
|
describe '#perform!' do
|
||||||
it 'calls .create_visibilities' do
|
it 'calls .create_post_visibilities' do
|
||||||
receiver.should_receive(:create_visibilities)
|
receiver.should_receive(:create_post_visibilities)
|
||||||
receiver.perform!
|
receiver.perform!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -39,10 +39,10 @@ describe Postzord::Receiver::LocalPostBatch do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create_visibilities' do
|
describe '#create_post_visibilities' do
|
||||||
it 'calls Postvisibility.batch_import' do
|
it 'calls Postvisibility.batch_import' do
|
||||||
PostVisibility.should_receive(:batch_import)
|
PostVisibility.should_receive(:batch_import)
|
||||||
receiver.create_visibilities
|
receiver.create_post_visibilities
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ describe Postzord::Receiver::LocalPostBatch do
|
||||||
:author => alice.person,
|
:author => alice.person,
|
||||||
:text => "Hey @{Bob; #{bob.diaspora_handle}}")
|
:text => "Hey @{Bob; #{bob.diaspora_handle}}")
|
||||||
|
|
||||||
receiver2 = Postzord::Receiver::LocalPostBatch.new(sm, @ids)
|
receiver2 = Postzord::Receiver::LocalBatch.new(sm, @ids)
|
||||||
Notification.should_receive(:notify).with(bob, anything, alice.person)
|
Notification.should_receive(:notify).with(bob, anything, alice.person)
|
||||||
receiver2.notify_mentioned_users
|
receiver2.notify_mentioned_users
|
||||||
end
|
end
|
||||||
|
|
@ -76,13 +76,13 @@ describe Postzord::Receiver::LocalPostBatch do
|
||||||
it 'calls notify for posts with notification type' do
|
it 'calls notify for posts with notification type' do
|
||||||
reshare = Factory.create(:reshare)
|
reshare = Factory.create(:reshare)
|
||||||
Notification.should_receive(:notify)
|
Notification.should_receive(:notify)
|
||||||
receiver = Postzord::Receiver::LocalPostBatch.new(reshare, @ids)
|
receiver = Postzord::Receiver::LocalBatch.new(reshare, @ids)
|
||||||
receiver.notify_users
|
receiver.notify_users
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calls notify for posts with notification type' do
|
it 'calls notify for posts with notification type' do
|
||||||
sm = Factory.create(:status_message, :author => alice.person)
|
sm = Factory.create(:status_message, :author => alice.person)
|
||||||
receiver = Postzord::Receiver::LocalPostBatch.new(sm, @ids)
|
receiver = Postzord::Receiver::LocalBatch.new(sm, @ids)
|
||||||
Notification.should_not_receive(:notify)
|
Notification.should_not_receive(:notify)
|
||||||
receiver.notify_users
|
receiver.notify_users
|
||||||
end
|
end
|
||||||
|
|
@ -102,7 +102,7 @@ describe Postzord::Receiver::LocalPostBatch do
|
||||||
|
|
||||||
it 'does not call create_visibilities and notify_mentioned_users' do
|
it 'does not call create_visibilities and notify_mentioned_users' do
|
||||||
receiver.should_not_receive(:notify_mentioned_users)
|
receiver.should_not_receive(:notify_mentioned_users)
|
||||||
receiver.should_not_receive(:create_visibilities)
|
receiver.should_not_receive(:create_post_visibilities)
|
||||||
receiver.perform!
|
receiver.perform!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -102,9 +102,9 @@ describe Postzord::Receiver::Public do
|
||||||
comment = stub.as_null_object
|
comment = stub.as_null_object
|
||||||
@receiver.instance_variable_set(:@object, comment)
|
@receiver.instance_variable_set(:@object, comment)
|
||||||
|
|
||||||
local_post_batch_receiver = stub.as_null_object
|
local_batch_receiver = stub.as_null_object
|
||||||
Postzord::Receiver::LocalPostBatch.stub(:new).and_return(local_post_batch_receiver)
|
Postzord::Receiver::LocalBatch.stub(:new).and_return(local_batch_receiver)
|
||||||
local_post_batch_receiver.should_receive(:notify_users)
|
local_batch_receiver.should_receive(:notify_users)
|
||||||
@receiver.receive_relayable
|
@receiver.receive_relayable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ describe Jobs::ReceiveLocalBatch do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.perform' do
|
describe '.perform' do
|
||||||
it 'calls Postzord::Receiver::LocalPostBatch' do
|
it 'calls Postzord::Receiver::LocalBatch' do
|
||||||
pending
|
pending
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue