Limit allowed contacts for sending messages to, to the ones that are sharing with you.

This commit is contained in:
Stephan Schulz 2012-03-23 01:16:50 +01:00
parent 47dbced6d7
commit 716315409a
2 changed files with 5 additions and 3 deletions

View file

@ -70,7 +70,7 @@ class ConversationsController < ApplicationController
def new def new
all_contacts_and_ids = Contact.connection.select_rows( all_contacts_and_ids = Contact.connection.select_rows(
current_user.contacts.joins(:person => :profile). current_user.contacts.where(:sharing => true).joins(:person => :profile).
select("contacts.id, profiles.first_name, profiles.last_name, people.diaspora_handle").to_sql select("contacts.id, profiles.first_name, profiles.last_name, people.diaspora_handle").to_sql
).map{|r| {:value => r[0], :name => Person.name_from_attrs(r[1], r[2], r[3]).gsub(/(")/, "'")} } ).map{|r| {:value => r[0], :name => Person.name_from_attrs(r[1], r[2], r[3]).gsub(/(")/, "'")} }

View file

@ -18,8 +18,10 @@ describe ConversationsController do
response.should be_success response.should be_success
end end
it "assigns a json list of contacts" do it "assigns a json list of contacts that are sharing with the person" do
assigns(:contacts_json).should include(alice.contacts.first.person.name) assigns(:contacts_json).should include(alice.contacts.where(:sharing => true).first.person.name)
alice.contacts << Contact.new(:person_id => eve.person.id, :user_id => alice.id, :sharing => false, :receiving => true)
assigns(:contacts_json).should_not include(alice.contacts.where(:sharing => false).first.person.name)
end end
it "assigns a contact if passed a contact id" do it "assigns a contact if passed a contact id" do