From fe4c8a771bd1eab1bffebcb08d07e2e4c0015955 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 28 Oct 2015 01:24:58 +0000 Subject: [PATCH] Replace text with nickname if shorter --- plugins/OStatus/OStatusPlugin.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 1fe6e54fa6..2b412d73e0 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -278,9 +278,11 @@ class OStatusPlugin extends Plugin $oprofile = Ostatus_profile::ensureWebfinger($target); if ($oprofile instanceof Ostatus_profile && !$oprofile->isGroup()) { $profile = $oprofile->localProfile(); + $text = !empty($profile->nickname) && strlen($profile->nickname) < strlen($target) ? + $profile->nickname : $target; $matches[$pos] = array('mentioned' => array($profile), 'type' => 'mention', - 'text' => $target, + 'text' => $text, 'position' => $pos, 'length' => mb_strlen($target), 'url' => $profile->getUrl()); @@ -306,9 +308,11 @@ class OStatusPlugin extends Plugin $oprofile = Ostatus_profile::ensureProfileURL($url); if ($oprofile instanceof Ostatus_profile && !$oprofile->isGroup()) { $profile = $oprofile->localProfile(); + $text = !empty($profile->nickname) && strlen($profile->nickname) < strlen($target) ? + $profile->nickname : $target; $matches[$pos] = array('mentioned' => array($profile), 'type' => 'mention', - 'text' => $target, + 'text' => $text, 'position' => $pos, 'length' => mb_strlen($target), 'url' => $profile->getUrl()); -- 2.39.5