Skip to content
Extraits de code Groupes Projets
Valider 610700ff rédigé par Steffen van Bergerem's avatar Steffen van Bergerem Validation de Benjamin Neff
Parcourir les fichiers

Refactor conversations controller create

closes #7224
parent 3586fa6a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -38,21 +38,22 @@ class ConversationsController < ApplicationController
person_ids = current_user.contacts.mutual.where(column => params[recipients_param].split(",")).pluck(:person_id)
end
unless person_ids.present?
render text: I18n.t("javascripts.conversation.create.no_recipient"), status: 422
return
end
opts = params.require(:conversation).permit(:subject)
opts[:participant_ids] = person_ids
opts[:message] = { text: params[:conversation][:text] }
@conversation = current_user.build_conversation(opts)
if person_ids.present? && @conversation.save
if @conversation.save
Diaspora::Federation::Dispatcher.defer_dispatch(current_user, @conversation)
flash[:notice] = I18n.t("conversations.create.sent")
render json: {id: @conversation.id}
else
message = I18n.t("conversations.create.fail")
if person_ids.blank?
message = I18n.t("javascripts.conversation.create.no_recipient")
end
render text: message, status: 422
render text: I18n.t("conversations.create.fail"), status: 422
end
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter