diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 9f49c32ddbefb81c394906afe59ea0c8d49e89e7..a33407868b9c40dd4e802575e1daef2221593e29 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -40,14 +40,14 @@ class StatusMessagesController < ApplicationController @status_message = current_user.build_post(:status_message, params[:status_message]) + photos = Photo.where(:id => [*params[:photos]], :diaspora_handle => current_user.person.diaspora_handle) + unless photos.empty? + @status_message.photos << photos + end + if @status_message.save Rails.logger.info("event=create type=status_message chars=#{params[:status_message][:text].length}") - photos = Photo.where(:id => [*params[:photos]], :diaspora_handle => current_user.person.diaspora_handle) - if !photos.empty? - @status_message.photos << photos - end - aspects = current_user.aspects_from_ids(params[:aspect_ids]) current_user.add_to_streams(@status_message, aspects) receiving_services = current_user.services.where( :type => params[:services].map{|s| "Services::"+s.titleize}) if params[:services] @@ -64,6 +64,9 @@ class StatusMessagesController < ApplicationController format.mobile{ redirect_to root_url} end else + unless photos.empty? + photos.update_all(:status_message_guid => nil) + end respond_to do |format| format.js {