I'm still not sure when it's useful to reset a notice's author
This commit is contained in:
parent
4b41d05a13
commit
1a81356622
@ -72,7 +72,7 @@ class ActivityImporter extends QueueHandler
|
|||||||
$this->joinGroup($user, $activity);
|
$this->joinGroup($user, $activity);
|
||||||
break;
|
break;
|
||||||
case ActivityVerb::POST:
|
case ActivityVerb::POST:
|
||||||
$this->postNote($user, $activity);
|
$this->postNote($user, $author, $activity);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unknown verb: {$activity->verb}");
|
throw new Exception("Unknown verb: {$activity->verb}");
|
||||||
@ -141,13 +141,17 @@ class ActivityImporter extends QueueHandler
|
|||||||
if (empty($group)) {
|
if (empty($group)) {
|
||||||
$oprofile = Ostatus_profile::ensureActivityObjectProfile($activity->objects[0]);
|
$oprofile = Ostatus_profile::ensureActivityObjectProfile($activity->objects[0]);
|
||||||
if (!$oprofile->isGroup()) {
|
if (!$oprofile->isGroup()) {
|
||||||
throw new Exception("Remote profile is not a group!");
|
throw new ClientException("Remote profile is not a group!");
|
||||||
}
|
}
|
||||||
$group = $oprofile->localGroup();
|
$group = $oprofile->localGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!empty($group));
|
assert(!empty($group));
|
||||||
|
|
||||||
|
if ($user->isMember($group)) {
|
||||||
|
throw new ClientException("User is already a member of this group.");
|
||||||
|
}
|
||||||
|
|
||||||
if (Event::handle('StartJoinGroup', array($group, $user))) {
|
if (Event::handle('StartJoinGroup', array($group, $user))) {
|
||||||
Group_member::join($group->id, $user->id);
|
Group_member::join($group->id, $user->id);
|
||||||
Event::handle('EndJoinGroup', array($group, $user));
|
Event::handle('EndJoinGroup', array($group, $user));
|
||||||
@ -156,7 +160,7 @@ class ActivityImporter extends QueueHandler
|
|||||||
|
|
||||||
// XXX: largely cadged from Ostatus_profile::processNote()
|
// XXX: largely cadged from Ostatus_profile::processNote()
|
||||||
|
|
||||||
function postNote($user, $activity)
|
function postNote($user, $author, $activity)
|
||||||
{
|
{
|
||||||
$note = $activity->objects[0];
|
$note = $activity->objects[0];
|
||||||
|
|
||||||
@ -165,11 +169,27 @@ class ActivityImporter extends QueueHandler
|
|||||||
$notice = Notice::staticGet('uri', $sourceUri);
|
$notice = Notice::staticGet('uri', $sourceUri);
|
||||||
|
|
||||||
if (!empty($notice)) {
|
if (!empty($notice)) {
|
||||||
// This is weird.
|
|
||||||
$orig = clone($notice);
|
common_log(LOG_INFO, "Notice {$sourceUri} already exists.");
|
||||||
$notice->profile_id = $user->id;
|
|
||||||
$notice->update($orig);
|
if ($this->trusted) {
|
||||||
return;
|
|
||||||
|
$profile = $notice->getProfile();
|
||||||
|
|
||||||
|
$uri = $profile->getUri();
|
||||||
|
|
||||||
|
if ($uri == $author->id) {
|
||||||
|
common_log(LOG_INFO, "Updating notice author from $author->id to $user->uri");
|
||||||
|
$orig = clone($notice);
|
||||||
|
$notice->profile_id = $user->id;
|
||||||
|
$notice->update($orig);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw new ClientException(sprintf(_("Already know about notice %s and ".
|
||||||
|
" it's got a different author %s."),
|
||||||
|
$sourceUri, $uri));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use summary as fallback for content
|
// Use summary as fallback for content
|
||||||
@ -199,7 +219,8 @@ class ActivityImporter extends QueueHandler
|
|||||||
'replies' => array(),
|
'replies' => array(),
|
||||||
'groups' => array(),
|
'groups' => array(),
|
||||||
'tags' => array(),
|
'tags' => array(),
|
||||||
'urls' => array());
|
'urls' => array(),
|
||||||
|
'distribute' => false);
|
||||||
|
|
||||||
// Check for optional attributes...
|
// Check for optional attributes...
|
||||||
|
|
||||||
@ -251,6 +272,8 @@ class ActivityImporter extends QueueHandler
|
|||||||
$options['urls'][] = $href;
|
$options['urls'][] = $href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common_log(LOG_INFO, "Saving notice {$options['uri']}");
|
||||||
|
|
||||||
$saved = Notice::saveNew($user->id,
|
$saved = Notice::saveNew($user->id,
|
||||||
$content,
|
$content,
|
||||||
'restore', // TODO: restore the actual source
|
'restore', // TODO: restore the actual source
|
||||||
|
Loading…
Reference in New Issue
Block a user