Commit 7c68537b authored by mmn's avatar mmn

Deletes now federated. But might not be handled properly

parent db9f68e6
......@@ -286,6 +286,12 @@ class Notice extends Managed_DataObject
: $this->object_type;
}
// activity plugins tend to use this function instead, but it's the same
public function getObjectType()
{
return $this->get_object_type();
}
public static function getByUri($uri)
{
$notice = new Notice();
......
......@@ -96,7 +96,7 @@ class ActivityModerationPlugin extends ActivityVerbHandlerPlugin
$deleted->id = $target->getID();
$deleted->profile_id = $target->getProfile()->getID();
$deleted->uri = Deleted_notice::newUri($target->getProfile(), $target);
$deleted->uri = $act->id;
$deleted->act_uri = $target->getUri();
$deleted->act_created = $target->created;
$deleted->created = common_sql_now();
......@@ -112,6 +112,25 @@ class ActivityModerationPlugin extends ActivityVerbHandlerPlugin
return $deleted;
}
// FIXME: Put this in lib/activityhandlerplugin.php when we're ready
// with the other microapps/activityhandlers as well.
// Also it should be StartNoticeAsActivity (with a prepped Activity, including ->context etc.)
public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null)
{
if (!$this->isMyNotice($stored)) {
return true;
}
common_debug('Extending activity '.$stored->id.' with '.get_called_class());
$this->extendActivity($stored, $act, $scoped);
return false;
}
public function extendActivity(Notice $stored, Activity $act, Profile $scoped=null)
{
Deleted_notice::extendActivity($stored, $act, $scoped);
}
public function activityObjectFromNotice(Notice $notice)
{
$object = Deleted_notice::fromStored($notice);
......
......@@ -69,10 +69,7 @@ class Deleted_notice extends Managed_DataObject
$act->type = ActivityObject::ACTIVITY;
$act->verb = ActivityVerb::DELETE;
$act->time = time();
$act->id = TagURI::mint('deleted_notice:%d:%d:%s',
$actor->getID(),
$notice->getID(),
common_date_iso8601(common_sql_now()));
$act->id = self::newUri($actor, $notice);
$act->content = sprintf(_m('<a href="%1$s">%2$s</a> deleted notice <a href="%3$s">{{%4$s}}</a>.'),
htmlspecialchars($actor->getUrl()),
......@@ -153,7 +150,6 @@ class Deleted_notice extends Managed_DataObject
$actobj->actor = $this->getActorObject();
$actobj->target = new ActivityObject();
$actobj->target->id = $this->getTargetUri();
$actobj->target->type = ActivityUtils::resolveUri(self::getObjectType());
$actobj->objects = array(clone($actobj->target));
$actobj->verb = ActivityVerb::DELETE;
$actobj->title = ActivityUtils::verbToTitle($actobj->verb);
......@@ -168,6 +164,17 @@ class Deleted_notice extends Managed_DataObject
return $actobj;
}
static public function extendActivity(Notice $stored, Activity $act, Profile $scoped=null)
{
$object = self::fromStored($stored);
$act->target = $object->asActivityObject();
$act->objects = array(clone($act->target));
$act->context->replyToID = $object->getTargetUri();
$act->title = ActivityUtils::verbToTitle($act->verb);
}
static function newUri(Profile $actor, Managed_DataObject $object, $created=null)
{
if (is_null($created)) {
......@@ -175,7 +182,7 @@ class Deleted_notice extends Managed_DataObject
}
return TagURI::mint(strtolower(get_called_class()).':%d:%s:%d:%s',
$actor->getID(),
ActivityUtils::resolveUri(self::getObjectType(), true),
ActivityUtils::resolveUri($object->getObjectType(), true),
$object->getID(),
common_date_iso8601($created));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment