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|
|
||||
ConversationVisibility.find_or_create_by_conversation_id_and_person_id(cnv.id, participant.id)
|
||||
end
|
||||
|
||||
self.messages.each do |msg|
|
||||
msg.conversation_id = cnv.id
|
||||
received_msg = msg.receive(user, person)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
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
|
||||
class ReceiveLocalBatch < Base
|
||||
|
|
@ -12,7 +12,7 @@ module Jobs
|
|||
|
||||
def self.perform(object_class_string, object_id, recipient_user_ids)
|
||||
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!
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
module Job
|
||||
module Jobs
|
||||
class PublishToHub < Base
|
||||
@queue = :http_service
|
||||
def self.perform(sender_public_url)
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class Postzord::Dispatcher
|
|||
# @param people [Array<Person>] Recipients of the post
|
||||
def deliver_to_local(people)
|
||||
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)
|
||||
else
|
||||
people.each do |person|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
module Postzord
|
||||
module Receiver
|
||||
class LocalPostBatch
|
||||
class LocalBatch
|
||||
attr_reader :object, :recipient_user_ids, :users
|
||||
|
||||
def initialize(object, recipient_user_ids)
|
||||
|
|
@ -13,7 +13,7 @@ module Postzord
|
|||
if @object.respond_to?(:relayable?)
|
||||
receive_relayable
|
||||
else
|
||||
create_visibilities
|
||||
create_post_visibilities
|
||||
end
|
||||
notify_mentioned_users if @object.respond_to?(:mentions)
|
||||
|
||||
|
|
@ -31,10 +31,10 @@ module Postzord
|
|||
@object
|
||||
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
|
||||
# @return [void]
|
||||
def create_visibilities
|
||||
def create_post_visibilities
|
||||
contacts = Contact.where(:user_id => @recipient_user_ids, :person_id => @object.author_id)
|
||||
PostVisibility.batch_import(contacts, object)
|
||||
end
|
||||
|
|
@ -49,7 +49,6 @@ module Postzord
|
|||
obj
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
def salmon
|
||||
@salmon ||= Salmon::EncryptedSlap.from_xml(@salmon_xml, @user)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ module Postzord
|
|||
@object.receive(@object.parent.author.owner, @author)
|
||||
end
|
||||
# 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
|
||||
@object
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
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
|
||||
@object = Factory(:status_message, :author => alice.person)
|
||||
@ids = [bob.id]
|
||||
end
|
||||
|
||||
let(:receiver) { Postzord::Receiver::LocalPostBatch.new(@object, @ids) }
|
||||
let(:receiver) { Postzord::Receiver::LocalBatch.new(@object, @ids) }
|
||||
|
||||
describe '.initialize' do
|
||||
it 'sets @post, @recipient_user_ids, and @user' do
|
||||
|
|
@ -18,8 +18,8 @@ describe Postzord::Receiver::LocalPostBatch do
|
|||
end
|
||||
|
||||
describe '#perform!' do
|
||||
it 'calls .create_visibilities' do
|
||||
receiver.should_receive(:create_visibilities)
|
||||
it 'calls .create_post_visibilities' do
|
||||
receiver.should_receive(:create_post_visibilities)
|
||||
receiver.perform!
|
||||
end
|
||||
|
||||
|
|
@ -39,10 +39,10 @@ describe Postzord::Receiver::LocalPostBatch do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#create_visibilities' do
|
||||
describe '#create_post_visibilities' do
|
||||
it 'calls Postvisibility.batch_import' do
|
||||
PostVisibility.should_receive(:batch_import)
|
||||
receiver.create_visibilities
|
||||
receiver.create_post_visibilities
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ describe Postzord::Receiver::LocalPostBatch do
|
|||
:author => alice.person,
|
||||
: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)
|
||||
receiver2.notify_mentioned_users
|
||||
end
|
||||
|
|
@ -76,13 +76,13 @@ describe Postzord::Receiver::LocalPostBatch do
|
|||
it 'calls notify for posts with notification type' do
|
||||
reshare = Factory.create(:reshare)
|
||||
Notification.should_receive(:notify)
|
||||
receiver = Postzord::Receiver::LocalPostBatch.new(reshare, @ids)
|
||||
receiver = Postzord::Receiver::LocalBatch.new(reshare, @ids)
|
||||
receiver.notify_users
|
||||
end
|
||||
|
||||
it 'calls notify for posts with notification type' do
|
||||
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)
|
||||
receiver.notify_users
|
||||
end
|
||||
|
|
@ -102,7 +102,7 @@ describe Postzord::Receiver::LocalPostBatch do
|
|||
|
||||
it 'does not call create_visibilities and notify_mentioned_users' do
|
||||
receiver.should_not_receive(:notify_mentioned_users)
|
||||
receiver.should_not_receive(:create_visibilities)
|
||||
receiver.should_not_receive(:create_post_visibilities)
|
||||
receiver.perform!
|
||||
end
|
||||
end
|
||||
|
|
@ -102,9 +102,9 @@ describe Postzord::Receiver::Public do
|
|||
comment = stub.as_null_object
|
||||
@receiver.instance_variable_set(:@object, comment)
|
||||
|
||||
local_post_batch_receiver = stub.as_null_object
|
||||
Postzord::Receiver::LocalPostBatch.stub(:new).and_return(local_post_batch_receiver)
|
||||
local_post_batch_receiver.should_receive(:notify_users)
|
||||
local_batch_receiver = stub.as_null_object
|
||||
Postzord::Receiver::LocalBatch.stub(:new).and_return(local_batch_receiver)
|
||||
local_batch_receiver.should_receive(:notify_users)
|
||||
@receiver.receive_relayable
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ describe Jobs::ReceiveLocalBatch do
|
|||
end
|
||||
|
||||
describe '.perform' do
|
||||
it 'calls Postzord::Receiver::LocalPostBatch' do
|
||||
it 'calls Postzord::Receiver::LocalBatch' do
|
||||
pending
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue