Handle normalized acct: URIs in ostatussub

Mastodon sent the proper acct: URI and not just 'user@domain' when
using the remote subscribe functionality.
This commit is contained in:
Mikael Nordfeldth 2017-04-16 11:01:16 +02:00
parent 9fead39f36
commit 388655d19b
2 changed files with 6 additions and 4 deletions

View File

@ -242,9 +242,9 @@ class OStatusSubAction extends Action
function pullRemoteProfile()
{
$validate = new Validate();
$this->profile_uri = $this->trimmed('profile');
$this->profile_uri = Discovery::normalize($this->trimmed('profile'));
try {
if ($validate->email($this->profile_uri)) {
if (Discovery::isAcct($this->profile_uri) && $validate->email(mb_substr($this->profile_uri, 5))) {
$this->oprofile = Ostatus_profile::ensureWebfinger($this->profile_uri);
} else if ($validate->uri($this->profile_uri)) {
$this->oprofile = Ostatus_profile::ensureProfileURL($this->profile_uri);

View File

@ -1561,8 +1561,10 @@ class Ostatus_profile extends Managed_DataObject
*/
public static function ensureWebfinger($addr)
{
// First, try the cache
// Normalize $addr, i.e. add 'acct:' if missing
$addr = Discovery::normalize($addr);
// Try the cache
$uri = self::cacheGet(sprintf('ostatus_profile:webfinger:%s', $addr));
if ($uri !== false) {
@ -1578,7 +1580,7 @@ class Ostatus_profile extends Managed_DataObject
}
// Try looking it up
$oprofile = Ostatus_profile::getKV('uri', Discovery::normalize($addr));
$oprofile = Ostatus_profile::getKV('uri', $addr);
if ($oprofile instanceof Ostatus_profile) {
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());