Revert "add participant_users to conversations"
This reverts commit655558cb95. Revert "MS DG; for real this time?" This reverts commitf85a047f6f. Revert "MS DG; actually fix the bug" This reverts commitcde12ec232. Revert "fix small commenting email bug #oops" This reverts commita552fc80c0. Revert "dont ban diasporahq stuff" This reverts commit2c12b94e67. Revert "Merge branch 'participants'" This reverts commit7417801886, reversing changes made toabd211ba72.
This commit is contained in:
parent
74892b33da
commit
c9f069d000
15 changed files with 22 additions and 73 deletions
|
|
@ -59,7 +59,7 @@ class Comment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def notification_type(user, person)
|
||||
if (self.post.author == user.person) && (self.author != user.person)
|
||||
if self.post.author == user.person
|
||||
return Notifications::CommentOnPost
|
||||
elsif self.post.comments.where(:author_id => user.person.id) != [] && self.author_id != user.person.id
|
||||
return Notifications::AlsoCommented
|
||||
|
|
|
|||
|
|
@ -36,20 +36,12 @@ class Conversation < ActiveRecord::Base
|
|||
def participant_handles
|
||||
self.participants.map{|p| p.diaspora_handle}.join(";")
|
||||
end
|
||||
|
||||
def participant_handles= handles
|
||||
handles.split(';').each do |handle|
|
||||
self.participants << Webfinger.new(handle).fetch
|
||||
end
|
||||
end
|
||||
|
||||
def participant_users
|
||||
@participant_users ||= lambda do
|
||||
user_ids = self.participants.map {|p| p.owner_id}.compact
|
||||
User.where(:id => user_ids)
|
||||
end.call
|
||||
end
|
||||
|
||||
def last_author
|
||||
self.messages.last.author if self.messages.size > 0
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ module Jobs
|
|||
|
||||
def self.perform(user_id, encoded_object_xml, person_ids, dispatcher_class_as_string)
|
||||
user = User.find(user_id)
|
||||
|
||||
#could be bad here
|
||||
people = Person.where(:id => person_ids)
|
||||
|
||||
dispatcher = dispatcher_class_as_string.constantize
|
||||
|
|
|
|||
|
|
@ -9,12 +9,17 @@ module Jobs
|
|||
require File.join(Rails.root, 'app/models/notification')
|
||||
|
||||
def self.perform(user_ids, object_klass, object_id, person_id)
|
||||
|
||||
object = object_klass.constantize.find_by_id(object_id)
|
||||
users = object.participant_users
|
||||
|
||||
#hax
|
||||
return if (object.author.diaspora_handle == 'diasporahq@joindiaspora.com' || (object.respond_to?(:relayable?) && object.parent.author.diaspora_handle == 'diasporahq@joindiaspora.com'))
|
||||
#end hax
|
||||
|
||||
users = User.where(:id => user_ids)
|
||||
person = Person.find_by_id(person_id)
|
||||
users.each do |user|
|
||||
Notification.notify(user, object, person)
|
||||
end
|
||||
|
||||
users.each{|user| Notification.notify(user, object, person) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,11 +11,7 @@ module Jobs
|
|||
@queue = :receive
|
||||
|
||||
def self.perform(object_class_string, object_id, recipient_user_ids)
|
||||
|
||||
|
||||
object = object_class_string.constantize.find(object_id)
|
||||
|
||||
#recipient user ids could be really bad
|
||||
receiver = Postzord::Receiver::LocalBatch.new(object, recipient_user_ids)
|
||||
receiver.perform!
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
#
|
||||
class Notification < ActiveRecord::Base
|
||||
require File.join(Rails.root, 'lib/diaspora/web_socket')
|
||||
include Diaspora::Socketable
|
||||
|
|
@ -16,8 +16,6 @@ class Notification < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.notify(recipient, target, actor)
|
||||
return false if recipient.person == actor #never notify someone if they are the actor, derp
|
||||
|
||||
if target.respond_to? :notification_type
|
||||
if note_type = target.notification_type(recipient, actor)
|
||||
if(target.is_a? Comment) || (target.is_a? Like)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class Person < ActiveRecord::Base
|
|||
has_many :posts, :foreign_key => :author_id, :dependent => :destroy # This person's own posts
|
||||
has_many :photos, :foreign_key => :author_id, :dependent => :destroy # This person's own photos
|
||||
has_many :comments, :foreign_key => :author_id, :dependent => :destroy # This person's own comments
|
||||
has_many :likes, :foreign_key => :author_id, :dependent => :destroy # This person's own likes
|
||||
|
||||
belongs_to :owner, :class_name => 'User'
|
||||
|
||||
|
|
|
|||
|
|
@ -46,14 +46,6 @@ module Diaspora
|
|||
end
|
||||
end
|
||||
|
||||
def particpants
|
||||
self.parent.participants
|
||||
end
|
||||
|
||||
def participant_users
|
||||
self.parent.participant_users
|
||||
end
|
||||
|
||||
def receive(user, person=nil)
|
||||
comment_or_like = self.class.where(:guid => self.guid).first || self
|
||||
|
||||
|
|
|
|||
|
|
@ -107,28 +107,6 @@ module Diaspora
|
|||
end
|
||||
end
|
||||
|
||||
# @return [Array<Person>] The list of participants to this shareable
|
||||
def participants
|
||||
@participants ||= lambda do
|
||||
share_type = self.class.base_class.to_s
|
||||
people = []
|
||||
if self.respond_to? :comments
|
||||
people += Person.joins(:comments).where(:comments => {:commentable_id => self.id, :commentable_type => share_type}).all
|
||||
end
|
||||
|
||||
if self.respond_to? :likes
|
||||
people += Person.joins(:likes).where(:likes => {:target_id => self.id, :target_type => share_type}).all
|
||||
end
|
||||
people
|
||||
end.call
|
||||
end
|
||||
|
||||
def participant_users
|
||||
@participant_users ||= lambda do
|
||||
user_ids = participants.map{|x| x.owner_id}.compact
|
||||
User.where(:id => user_ids)
|
||||
end.call
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,15 @@ class Postzord::Dispatcher
|
|||
# @param services [Array<User>]
|
||||
def notify_users(users)
|
||||
return unless users.present? && @object.respond_to?(:persisted?)
|
||||
Resque.enqueue(Jobs::NotifyLocalUsers, users.map{|u| u.id}, @object.class.to_s, @object.id, @object.author.id)
|
||||
|
||||
#temp hax
|
||||
unless object_is_related_to_diaspora_hq?
|
||||
Resque.enqueue(Jobs::NotifyLocalUsers, users.map{|u| u.id}, @object.class.to_s, @object.id, @object.author.id)
|
||||
end
|
||||
end
|
||||
|
||||
def object_is_related_to_diaspora_hq?
|
||||
(@object.author.diaspora_handle == 'diasporahq@joindiaspora.com' || (@object.respond_to?(:relayable?) && @object.parent.author.diaspora_handle == 'diasporahq@joindiaspora.com'))
|
||||
end
|
||||
|
||||
# @param services [Array<User>]
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class Postzord::Receiver::LocalBatch < Postzord::Receiver
|
|||
def initialize(object, recipient_user_ids)
|
||||
@object = object
|
||||
@recipient_user_ids = recipient_user_ids
|
||||
#this is a nightmare
|
||||
@users = User.where(:id => @recipient_user_ids)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -117,4 +117,5 @@ class Stream::Multi < Stream::Base
|
|||
def ids(query)
|
||||
Post.connection.select_values(query.for_a_stream(max_time, order).select('posts.id').to_sql)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -36,12 +36,6 @@ describe Comment do
|
|||
@comment.notification_type(alice, alice.person).should == Notifications::AlsoCommented
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not return if you are author of the object being commented on' do
|
||||
p = Factory(:status_message, :author => bob.person)
|
||||
c = bob.comment("dfs", :post => p)
|
||||
c.notification_type(bob, bob.person).should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe 'User#comment' do
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ describe Jobs::NotifyLocalUsers do
|
|||
post = Factory :status_message
|
||||
|
||||
StatusMessage.should_receive(:find_by_id).with(post.id).and_return(post)
|
||||
post.should_receive(:participant_users).and_return([alice, eve])
|
||||
#User.should_receive(:where).and_return([alice, eve])
|
||||
Notification.should_receive(:notify).with(instance_of(User), instance_of(StatusMessage), instance_of(Person)).twice
|
||||
|
||||
Jobs::NotifyLocalUsers.perform([alice.id, eve.id], post.class.to_s, post.id, person.id)
|
||||
|
|
|
|||
|
|
@ -195,17 +195,6 @@ describe Post do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#participants' do
|
||||
it 'only returns the people that commented and liked the post' do
|
||||
status = Factory(:status_message, :author => bob.person, :public => true)
|
||||
alice.comment('too', :post => status)
|
||||
eve.like(true, :target => status)
|
||||
|
||||
status.participants.map(&:id).should =~ [alice, eve].map{|x| x.person.id}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#comments' do
|
||||
it 'returns the comments of a post in created_at order' do
|
||||
post = bob.post :status_message, :text => "hello", :to => 'all'
|
||||
|
|
|
|||
Loading…
Reference in a new issue