Update Profile Data script fixes, might work for groups too now
This commit is contained in:
parent
a93c69d150
commit
7bef2ad4cc
@ -301,7 +301,7 @@ class ActivityUtils
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFeedAuthor($feedEl)
|
static function getFeedAuthor(DOMDocument $feedEl)
|
||||||
{
|
{
|
||||||
// Try old and deprecated activity:subject
|
// Try old and deprecated activity:subject
|
||||||
|
|
||||||
|
@ -1281,6 +1281,12 @@ class Ostatus_profile extends Managed_DataObject
|
|||||||
*/
|
*/
|
||||||
public function updateFromActivityObject(ActivityObject $object, array $hints=array())
|
public function updateFromActivityObject(ActivityObject $object, array $hints=array())
|
||||||
{
|
{
|
||||||
|
if (self::getActivityObjectProfileURI($actorObj) !== $this->getUri()) {
|
||||||
|
common_log(LOG_ERR, 'Trying to update profile with URI '._ve($this->getUri()).' from ActivityObject with URI: '._ve(self::getActivityObjectProfileURI($actorObj)));
|
||||||
|
// FIXME: Maybe not AuthorizationException?
|
||||||
|
throw new AuthorizationException('Trying to update profile from ActivityObject with different URI.');
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->isGroup()) {
|
if ($this->isGroup()) {
|
||||||
$group = $this->localGroup();
|
$group = $this->localGroup();
|
||||||
self::updateGroup($group, $object, $hints);
|
self::updateGroup($group, $object, $hints);
|
||||||
|
@ -62,15 +62,16 @@ function fixProfile(Ostatus_profile $oprofile) {
|
|||||||
echo "Updating profile from feed: $feedurl\n";
|
echo "Updating profile from feed: $feedurl\n";
|
||||||
$dom = new DOMDocument();
|
$dom = new DOMDocument();
|
||||||
if ($dom->loadXML($response->getBody())) {
|
if ($dom->loadXML($response->getBody())) {
|
||||||
$feed = $dom->documentElement;
|
if ($dom->documentElement->tagName !== 'feed') {
|
||||||
$entries = $dom->getElementsByTagNameNS(Activity::ATOM, 'entry');
|
echo " (no <feed> element in feed URL response; skipping)\n";
|
||||||
if ($entries->length) {
|
return false;
|
||||||
$entry = $entries->item(0);
|
}
|
||||||
$activity = new Activity($entry, $feed);
|
$actorObj = ActivityUtils::getFeedAuthor($dom->documentElement);
|
||||||
$oprofile->checkAuthorship($activity);
|
if ($actorObj) {
|
||||||
|
$oprofile->updateFromActivityObject($actorObj);
|
||||||
echo " (ok)\n";
|
echo " (ok)\n";
|
||||||
} else {
|
} else {
|
||||||
echo " (no entry; skipping)\n";
|
echo " (no author on feed; skipping)\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user