]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
OStatus: when finding webfinger @-replies, override a local profile match if found...
authorBrion Vibber <brion@pobox.com>
Thu, 25 Feb 2010 02:43:55 +0000 (02:43 +0000)
committerBrion Vibber <brion@pobox.com>
Thu, 25 Feb 2010 02:56:56 +0000 (02:56 +0000)
Fixes inconsistent application of webfinger @-mentions in OStatus; once a local profile is set up the local name would often match first and ended up overriding in output.

plugins/OStatus/OStatusPlugin.php

index 5feb53b2600cabbbea25330abbfa2562dbb07fc1..7f75b7b2b4aff75995e0cf2adc764827bc05f02d 100644 (file)
@@ -210,7 +210,7 @@ class OStatusPlugin extends Plugin
      *
      */
 
-    function onStartFindMentions($sender, $text, &$mentions)
+    function onEndFindMentions($sender, $text, &$mentions)
     {
         preg_match_all('/(?:^|\s+)@((?:\w+\.)*\w+@(?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+)/',
                        $text,
@@ -233,11 +233,21 @@ class OStatusPlugin extends Plugin
 
                 $this->log(LOG_INFO, "Ostatus_profile found for address '$webfinger'");
 
+                if ($oprofile->isGroup()) {
+                    continue;
+                }
                 $profile = $oprofile->localProfile();
 
+                $pos = $wmatch[1];
+                foreach ($mentions as $i => $other) {
+                    // If we share a common prefix with a local user, override it!
+                    if ($other['position'] == $pos) {
+                        unset($mentions[$i]);
+                    }
+                }
                 $mentions[] = array('mentioned' => array($profile),
                                     'text' => $wmatch[0],
-                                    'position' => $wmatch[1],
+                                    'position' => $pos,
                                     'url' => $profile->profileurl);
             }
         }