Do proper fromUri lookup on groups too

This commit is contained in:
Mikael Nordfeldth 2016-01-09 14:36:47 +01:00
parent 55aa68b941
commit c3c5a9974d
3 changed files with 16 additions and 7 deletions

View File

@ -974,8 +974,6 @@ class Notice extends Managed_DataObject
// reasonably handle notifications themselves. // reasonably handle notifications themselves.
if (ActivityUtils::compareVerbs($stored->verb, array(ActivityVerb::POST))) { if (ActivityUtils::compareVerbs($stored->verb, array(ActivityVerb::POST))) {
$stored->saveAttentions($act->context->attention);
if (!empty($tags)) { if (!empty($tags)) {
$stored->saveKnownTags($tags); $stored->saveKnownTags($tags);
} else { } else {
@ -984,7 +982,7 @@ class Notice extends Managed_DataObject
// Note: groups may save tags, so must be run after tags are saved // Note: groups may save tags, so must be run after tags are saved
// to avoid errors on duplicates. // to avoid errors on duplicates.
// Note: groups should always be set. $stored->saveAttentions($act->context->attention);
if (!empty($urls)) { if (!empty($urls)) {
$stored->saveKnownUrls($urls); $stored->saveKnownUrls($urls);

View File

@ -1555,6 +1555,11 @@ class Profile extends Managed_DataObject
$user = User::getKV('uri', $uri); $user = User::getKV('uri', $uri);
if ($user instanceof User) { if ($user instanceof User) {
$profile = $user->getProfile(); $profile = $user->getProfile();
} else {
$group = User_group::getKV('uri', $uri);
if ($group instanceof User_group) {
$profile = $group->getProfile();
}
} }
Event::handle('EndGetProfileFromURI', array($uri, $profile)); Event::handle('EndGetProfileFromURI', array($uri, $profile));
} }

View File

@ -1265,17 +1265,23 @@ class OStatusPlugin extends Plugin
function onStartGetProfileFromURI($uri, &$profile) function onStartGetProfileFromURI($uri, &$profile)
{ {
// Don't want to do Web-based discovery on our own server, // Don't want to do Web-based discovery on our own server,
// so we check locally first. // so we check locally first. This duplicates the functionality
// in the Profile class, since the plugin always runs before
// that local lookup, but since we return false it won't run double.
$user = User::getKV('uri', $uri); $user = User::getKV('uri', $uri);
if ($user instanceof User) {
if (!empty($user)) {
$profile = $user->getProfile(); $profile = $user->getProfile();
return false; return false;
} else {
$group = User_group::getKV('uri', $uri);
if ($group instanceof User_group) {
$profile = $group->getProfile();
return false;
}
} }
// Now, check remotely // Now, check remotely
try { try {
$oprofile = Ostatus_profile::ensureProfileURI($uri); $oprofile = Ostatus_profile::ensureProfileURI($uri);
$profile = $oprofile->localProfile(); $profile = $oprofile->localProfile();