]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Replace text with nickname if shorter
authorStephen Paul Weber <singpolyma@singpolyma.net>
Wed, 28 Oct 2015 01:24:58 +0000 (01:24 +0000)
committerStephen Paul Weber <singpolyma@singpolyma.net>
Wed, 28 Oct 2015 01:24:58 +0000 (01:24 +0000)
plugins/OStatus/OStatusPlugin.php

index 1fe6e54fa66520adb5092772660c1a30d1bde015..2b412d73e0cae766aad00f02257a4be758933f43 100644 (file)
@@ -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());