Merge branch 'master' of github.com:diaspora/diaspora_rails into pivots
This commit is contained in:
commit
1d6e132a9f
7 changed files with 67 additions and 10 deletions
|
|
@ -28,9 +28,12 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@people_ids = @group.people.map {|p| p.id}
|
||||
@posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC'
|
||||
@people_ids = @group.person_ids
|
||||
|
||||
@group = Group.first(:id => params[:id])
|
||||
|
||||
@posts = current_user.posts_for( :group => @group ).paginate :order => 'created_at DESC'
|
||||
#@posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC'
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class SocketsController < ApplicationController
|
|||
include Rails.application.routes.url_helpers
|
||||
|
||||
def incoming(msg)
|
||||
puts "Got a connection to: #{msg}"
|
||||
Rails.logger.info("Socket received connection to: #{msg}")
|
||||
end
|
||||
|
||||
def outgoing(uid,object)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ module RequestsHelper
|
|||
url = nil
|
||||
local_person = Person.by_webfinger identifier
|
||||
if local_person
|
||||
action = (local_person == current_user.local_person ? :none : :friend)
|
||||
action = (local_person == current_user.person ? :none : :friend)
|
||||
url = local_person.receive_url
|
||||
elsif !(identifier.include?(request.host) || identifier.include?("localhost"))
|
||||
f = Redfinger.finger(identifier)
|
||||
|
|
|
|||
|
|
@ -53,10 +53,24 @@ class User
|
|||
model_class = class_name.to_s.camelize.constantize
|
||||
post = model_class.instantiate(options)
|
||||
post.creator_signature = post.sign_with_key(encryption_key)
|
||||
post.save
|
||||
post.notify_people
|
||||
post.socket_to_uid owner.id if (owner_id && post.respond_to?( :socket_to_uid))
|
||||
post.socket_to_uid owner.id if (owner_id && post.respond_to?(:socket_to_uid))
|
||||
|
||||
self.posts << post
|
||||
self.save
|
||||
|
||||
post
|
||||
end ######### Posts and Such ###############
|
||||
end
|
||||
|
||||
def posts_for( opts = {} )
|
||||
if opts[:group]
|
||||
group = self.groups.find_by_id( opts[:group].id )
|
||||
self.posts.find_all_by_person_id( (group.person_ids + [self.person.id] ), :order => "created_at desc")
|
||||
end
|
||||
end
|
||||
|
||||
######### Posts and Such ###############
|
||||
|
||||
def retract( post )
|
||||
retraction = Retraction.for(post)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ require "lib/diaspora/websocket"
|
|||
|
||||
sid = Diaspora::WebSocket.subscribe(ws.request['Path'].gsub('/',''), ws)
|
||||
|
||||
ws.onmessage { |msg| SocketsController.new.incoming(msg) }#@channel.push msg; puts msg}
|
||||
ws.onmessage { |msg| SocketsController.new.incoming(msg) }
|
||||
|
||||
ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,9 @@ class MessageHandler
|
|||
end
|
||||
|
||||
http.errback {
|
||||
puts http.response
|
||||
puts "failure from #{query.destination}, retrying"
|
||||
Rails.logger.info(http.response)
|
||||
Rails.logger.info("Failure from #{query.destination}, retrying...")
|
||||
|
||||
query.try_count +=1
|
||||
@queue.push query unless query.try_count >= NUM_TRIES
|
||||
process
|
||||
|
|
|
|||
|
|
@ -269,6 +269,12 @@ describe User do
|
|||
|
||||
@user.posts.count.should == 0
|
||||
end
|
||||
|
||||
it "should add the post to that user's posts when a user posts it" do
|
||||
status_message = @user.post :status_message, :message => "hi"
|
||||
@user.reload
|
||||
@user.posts.include?(status_message).should be true
|
||||
end
|
||||
|
||||
it 'should be removed on unfriending' do
|
||||
status_message = @user2.post :status_message, :message => "hi"
|
||||
|
|
@ -326,7 +332,7 @@ describe User do
|
|||
|
||||
it 'should not override userrefs on receive by another person' do
|
||||
@user3 = Factory.create :user
|
||||
@user3.activate_friend(@user2, @group3)
|
||||
@user3.activate_friend(@user2.person, @group3)
|
||||
|
||||
status_message = @user2.post :status_message, :message => "hi"
|
||||
@user.receive status_message.to_diaspora_xml
|
||||
|
|
@ -351,6 +357,39 @@ describe User do
|
|||
Post.count.should be 1
|
||||
end
|
||||
|
||||
describe 'group streams' do
|
||||
before do
|
||||
@group = @user.group(:name => 'heroes')
|
||||
@group2 = @user.group(:name => 'stuff')
|
||||
|
||||
@user2 = Factory.create :user
|
||||
@user.activate_friend(@user2.person, @group)
|
||||
|
||||
@user3 = Factory.create :user
|
||||
@user.activate_friend(@user3.person, @group2)
|
||||
|
||||
@user4 = Factory.create :user
|
||||
@user.activate_friend(@user4.person, @group2)
|
||||
end
|
||||
|
||||
it 'should generate a valid stream for a group of people' do
|
||||
status_message1 = @user2.post :status_message, :message => "hi"
|
||||
status_message2 = @user3.post :status_message, :message => "heyyyy"
|
||||
status_message3 = @user4.post :status_message, :message => "yooo"
|
||||
|
||||
@user.receive status_message1.to_diaspora_xml
|
||||
@user.receive status_message2.to_diaspora_xml
|
||||
@user.receive status_message3.to_diaspora_xml
|
||||
@user.reload
|
||||
|
||||
@user.posts_for(:group => @group).include?(status_message1).should be true
|
||||
@user.posts_for(:group => @group).include?(status_message2).should be false
|
||||
@user.posts_for(:group => @group).include?(status_message3).should be false
|
||||
|
||||
@user.posts_for(:group => @group2).include?(status_message1).should be false
|
||||
@user.posts_for(:group => @group2).include?(status_message2).should be true
|
||||
@user.posts_for(:group => @group2).include?(status_message3).should be true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue