diff --git a/Gemfile.lock b/Gemfile.lock index 966f201cd82c7fba808de9b53e5c17debc33dd2c..d255fbdbe4778d98b55cdf9e2ede4f4de7e68666 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -142,11 +142,7 @@ GEM childprocess (0.1.4) ffi (~> 0.6.3) closure-compiler (0.3.3) -<<<<<<< HEAD - cloudfiles (1.4.10) -======= cloudfiles (1.4.9) ->>>>>>> DG MS; status messages can now have photos. mime-types (>= 1.16) columnize (0.3.2) configuration (1.2.0) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 1bfabcdc348dda23ae099e8c34856f380fc179a1..3fa87c0cc8a12a3d4f48559923feabb15f28ea7b 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -9,7 +9,7 @@ class AspectsController < ApplicationController respond_to :json, :only => :show def index - @posts = current_user.visible_posts.paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' + @posts = current_user.visible_posts(:_type => "StatusMessage").paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' @aspect = :all if current_user.getting_started == true @@ -51,7 +51,7 @@ class AspectsController < ApplicationController render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 else @aspect_contacts = @aspect.contacts - @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC' + @posts = current_user.visible_posts( :by_members_of => @aspect, :_type => "StatusMessage" ).paginate :per_page => 15, :order => 'created_at DESC' respond_with @aspect end end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index c733e5106b2271e278f175482c186a982c01f828..e67d794c89cdc5bfe8752c13a58a5a51ff959d7e 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -40,7 +40,7 @@ class PeopleController < ApplicationController @pending_request = current_user.request_for(@person) end - @posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC' + @posts = current_user.visible_posts(:person_id => @person.id, :_type => "StatusMessage").paginate :page => params[:page], :order => 'created_at DESC' respond_with @person, :locals => {:post_type => :all} else diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 4a0c358bc8c14c20d93de2232ad10b68b7bb5f72..8e8f3c8a3bff572a40e8a37735477cfbe2190411 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -20,9 +20,9 @@ class StatusMessagesController < ApplicationController if @status_message.save(:safe => true) raise 'MongoMapper failed to catch a failed save' unless @status_message.id + @status_message.photos += photos unless photos.nil? current_user.dispatch_post(@status_message, :to => params[:status_message][:to]) - @status_message.photos += photos unless photos.nil? for photo in photos current_user.dispatch_post(photo, :to => params[:status_message][:to]) end diff --git a/app/models/photo.rb b/app/models/photo.rb index 87cf24068de9501cc0f25a4b646b58ae0a705201..285458437bf7ae3b41a13f9e61c10a5e4e4f8f71 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -15,6 +15,8 @@ class Photo < Post key :remote_photo_path key :remote_photo_name key :random_string + + key :status_message_id, ObjectId timestamps! @@ -25,7 +27,6 @@ class Photo < Post before_destroy :ensure_user_picture - def ownership_of_status_message message = StatusMessage.find_by_id(self.status_message_id) if status_message_id && message diff --git a/app/models/post.rb b/app/models/post.rb index cd4a666c10f85ce14d12f9bfccbc1e07430c2413..1037cc3fe7b6dcde69fd07592cb74a7d3aebd962 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -9,13 +9,13 @@ class Post include ApplicationHelper include ROXML include Diaspora::Webhooks - include Diaspora::Socketable xml_reader :_id xml_reader :diaspora_handle xml_reader :public xml_reader :created_at + key :public, Boolean, :default => false key :diaspora_handle, String diff --git a/app/models/status_message.rb b/app/models/status_message.rb index c859b165ab984c2ee2b5fde124116dc7cfe4b0e8..d2d4c580a5c7001204fde8c54ae65c1587fe9e82 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -3,13 +3,14 @@ # the COPYRIGHT file. class StatusMessage < Post + include Diaspora::Socketable validates_length_of :message, :maximum => 1000, :message => "please make your status messages less than 1000 characters" xml_name :status_message xml_reader :message key :message, String - many :photos, :class => Photo + many :photos, :class => Photo, :foreign_key => :status_message_id validates_presence_of :message attr_accessible :message diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index fbdc169a72f2adfb2475ce2758f1b58232958bd0..786aa9bda8a360647e1103d890438ba542f71a5e 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -13,10 +13,11 @@ module Diaspora def visible_posts( opts = {} ) opts[:order] ||= 'created_at DESC' opts[:pending] ||= false + opts[:_type] ||= ["StatusMessage","Photo"] if opts[:by_members_of] && opts[:by_members_of] != :all aspect = self.aspects.find_by_id( opts[:by_members_of].id ) - aspect.posts.find_all_by_pending(opts[:pending], :order => opts[:order]) + aspect.posts.find_all_by_pending_and__type(opts[:pending], opts[:_type], :order => opts[:order]) else self.raw_visible_posts.all(opts) end