git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit 58e232a1 authored by Brion Vibber's avatar Brion Vibber

OStatus: when finding webfinger @-replies, override a local profile match if...

OStatus: when finding webfinger @-replies, override a local profile match if found at the same location (eg @someguy vs @someguy@example.org)
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.
parent b798faf9
...@@ -210,7 +210,7 @@ class OStatusPlugin extends Plugin ...@@ -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+)/', preg_match_all('/(?:^|\s+)@((?:\w+\.)*\w+@(?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+)/',
$text, $text,
...@@ -233,11 +233,21 @@ class OStatusPlugin extends Plugin ...@@ -233,11 +233,21 @@ class OStatusPlugin extends Plugin
$this->log(LOG_INFO, "Ostatus_profile found for address '$webfinger'"); $this->log(LOG_INFO, "Ostatus_profile found for address '$webfinger'");
if ($oprofile->isGroup()) {
continue;
}
$profile = $oprofile->localProfile(); $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), $mentions[] = array('mentioned' => array($profile),
'text' => $wmatch[0], 'text' => $wmatch[0],
'position' => $wmatch[1], 'position' => $pos,
'url' => $profile->profileurl); 'url' => $profile->profileurl);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment