common_log(LOG_WARNING, $ce->getMessage());
return true;
} catch (ServerException $se) {
- common_log(LOG_ERR, $ce->getMessage());
+ common_log(LOG_ERR, $se->getMessage());
return false;
} catch (Exception $e) {
- common_log(LOG_ERR, $ce->getMessage());
+ common_log(LOG_ERR, $e->getMessage());
return false;
}
return true;
$profile = $user->getProfile();
if ($activity->objects[0]->id == $author->id) {
+
+ if (!$this->trusted) {
+ throw new ClientException(_("Can't force subscription for untrusted user."));
+ }
+
$other = $activity->actor;
$otherUser = User::staticGet('uri', $other->id);
if (empty($user)) {
if ($trusted) {
$user = $this->userFromAuthor($author);
+ } else {
+ throw new ClientException(_("Can't import without a user."));
}
}
- $entries = $feed->getElementsByTagNameNS(Activity::ATOM, 'entry');
-
- $activities = $this->entriesToActivities($entries, $feed);
+ $activities = $this->getActivities($feed);
$qm = QueueManager::get();
}
}
+ function getActivities($feed)
+ {
+ $entries = $feed->getElementsByTagNameNS(Activity::ATOM, 'entry');
+
+ $activities = array();
+
+ for ($i = 0; $i < $entries->length; $i++) {
+ $activities[] = new Activity($entries->item($i));
+ }
+
+ usort($activities, array("FeedImporter", "activitySort"));
+
+ return $activities;
+ }
+
+ /**
+ * Sort activities oldest-first
+ */
+
+ static function activitySort($a, $b)
+ {
+ if ($a->time == $b->time) {
+ return 0;
+ } else if ($a->time < $b->time) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+
function userFromAuthor($author)
{
$user = User::staticGet('uri', $author->id);
$user = null;
}
$xml = getActivityStreamDocument();
- $restorer = new AccountRestorer();
- $doc = $restorer->loadXML($xml);
- $restorer->importActivityStream($user, $doc);
+ $qm = QueueManager::get();
+ $qm->enqueue(array($user, $xml, true), 'feedimp');
} catch (Exception $e) {
print $e->getMessage()."\n";
exit(1);