diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2016-06-26 14:13:14 +0300 |
---|---|---|
committer | Benjamin Neff <benjamin@coding4coffee.ch> | 2016-06-26 15:05:52 +0300 |
commit | 9a3f653c4535e950a860743ed7c893cf36bb2ca5 (patch) | |
tree | 32eec46b097d60b326e1540bbad5c4c9a0f03a48 /app/controllers | |
parent | 9a033c7f68a237a1e9c0e4316d30abaaa02198e2 (diff) |
fix sender for messages for old pods
Send a second message to remote recipients with conversation-author
as salmon author if the conversation-author is local.
The first dispatch will fail on old pods. New pods will ignore the
second message, if the guid already exist.
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/messages_controller.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index fc6aacc16..c5387799b 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -15,9 +15,17 @@ class MessagesController < ApplicationController message = current_user.build_message(conversation, opts) if message.save - logger.info "event=create type=comment user=#{current_user.diaspora_handle} status=success " \ + logger.info "event=create type=message user=#{current_user.diaspora_handle} status=success " \ "message=#{message.id} chars=#{params[:message][:text].length}" Diaspora::Federation::Dispatcher.defer_dispatch(current_user, message) + + # TODO: can be removed when messages are not relayed anymore + conversation_owner = conversation.author.owner + if conversation_owner && conversation_owner != current_user + remote_subs = conversation.participants.remote.ids + opts = {subscriber_ids: remote_subs} + Diaspora::Federation::Dispatcher.defer_dispatch(conversation_owner, message, opts) unless remote_subs.empty? + end else flash[:error] = I18n.t('conversations.new_conversation.fail') end |