From d0fcdc254ec15420106a44d5f78c55d203836b33 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 25 Mar 2017 23:42:19 +0100 Subject: [PATCH] Only backport mention syntax when the author is local We don't need to change new to old syntax when we receive a post from a newer pod, since we can handle the new syntax. This is only needed when sending it to older pods. related to #7392 --- lib/diaspora/mentions_container.rb | 2 +- spec/shared_behaviors/mentions_container.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/diaspora/mentions_container.rb b/lib/diaspora/mentions_container.rb index 6aea4acf5..68e8b425c 100644 --- a/lib/diaspora/mentions_container.rb +++ b/lib/diaspora/mentions_container.rb @@ -5,7 +5,7 @@ module Diaspora included do before_create do # TODO: remove when most of the posts can handle the new syntax - self.text = Diaspora::Mentionable.backport_mention_syntax(text) if text + self.text = Diaspora::Mentionable.backport_mention_syntax(text) if text && author.local? end after_create :create_mentions diff --git a/spec/shared_behaviors/mentions_container.rb b/spec/shared_behaviors/mentions_container.rb index 42633e6e9..50e4efdc9 100644 --- a/spec/shared_behaviors/mentions_container.rb +++ b/spec/shared_behaviors/mentions_container.rb @@ -18,6 +18,13 @@ shared_examples_for "it is mentions container" do obj.save expect(obj.text).to eq(expected_text) end + + it "doesn't backport mention syntax if author is not local" do + text = "mention @{#{people[0].diaspora_handle}} text" + obj = FactoryGirl.build(described_class.to_s.underscore.to_sym, text: text, author: remote_raphael) + obj.save + expect(obj.text).to eq(text) + end end describe ".after_create" do