forked from GNUsocial/gnu-social
Deletes now federated. But might not be handled properly
This commit is contained in:
parent
db9f68e651
commit
7c68537b06
@ -286,6 +286,12 @@ class Notice extends Managed_DataObject
|
|||||||
: $this->object_type;
|
: $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)
|
public static function getByUri($uri)
|
||||||
{
|
{
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
|
@ -96,7 +96,7 @@ class ActivityModerationPlugin extends ActivityVerbHandlerPlugin
|
|||||||
|
|
||||||
$deleted->id = $target->getID();
|
$deleted->id = $target->getID();
|
||||||
$deleted->profile_id = $target->getProfile()->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_uri = $target->getUri();
|
||||||
$deleted->act_created = $target->created;
|
$deleted->act_created = $target->created;
|
||||||
$deleted->created = common_sql_now();
|
$deleted->created = common_sql_now();
|
||||||
@ -112,6 +112,25 @@ class ActivityModerationPlugin extends ActivityVerbHandlerPlugin
|
|||||||
return $deleted;
|
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)
|
public function activityObjectFromNotice(Notice $notice)
|
||||||
{
|
{
|
||||||
$object = Deleted_notice::fromStored($notice);
|
$object = Deleted_notice::fromStored($notice);
|
||||||
|
@ -69,10 +69,7 @@ class Deleted_notice extends Managed_DataObject
|
|||||||
$act->type = ActivityObject::ACTIVITY;
|
$act->type = ActivityObject::ACTIVITY;
|
||||||
$act->verb = ActivityVerb::DELETE;
|
$act->verb = ActivityVerb::DELETE;
|
||||||
$act->time = time();
|
$act->time = time();
|
||||||
$act->id = TagURI::mint('deleted_notice:%d:%d:%s',
|
$act->id = self::newUri($actor, $notice);
|
||||||
$actor->getID(),
|
|
||||||
$notice->getID(),
|
|
||||||
common_date_iso8601(common_sql_now()));
|
|
||||||
|
|
||||||
$act->content = sprintf(_m('<a href="%1$s">%2$s</a> deleted notice <a href="%3$s">{{%4$s}}</a>.'),
|
$act->content = sprintf(_m('<a href="%1$s">%2$s</a> deleted notice <a href="%3$s">{{%4$s}}</a>.'),
|
||||||
htmlspecialchars($actor->getUrl()),
|
htmlspecialchars($actor->getUrl()),
|
||||||
@ -153,7 +150,6 @@ class Deleted_notice extends Managed_DataObject
|
|||||||
$actobj->actor = $this->getActorObject();
|
$actobj->actor = $this->getActorObject();
|
||||||
$actobj->target = new ActivityObject();
|
$actobj->target = new ActivityObject();
|
||||||
$actobj->target->id = $this->getTargetUri();
|
$actobj->target->id = $this->getTargetUri();
|
||||||
$actobj->target->type = ActivityUtils::resolveUri(self::getObjectType());
|
|
||||||
$actobj->objects = array(clone($actobj->target));
|
$actobj->objects = array(clone($actobj->target));
|
||||||
$actobj->verb = ActivityVerb::DELETE;
|
$actobj->verb = ActivityVerb::DELETE;
|
||||||
$actobj->title = ActivityUtils::verbToTitle($actobj->verb);
|
$actobj->title = ActivityUtils::verbToTitle($actobj->verb);
|
||||||
@ -168,6 +164,17 @@ class Deleted_notice extends Managed_DataObject
|
|||||||
return $actobj;
|
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)
|
static function newUri(Profile $actor, Managed_DataObject $object, $created=null)
|
||||||
{
|
{
|
||||||
if (is_null($created)) {
|
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',
|
return TagURI::mint(strtolower(get_called_class()).':%d:%s:%d:%s',
|
||||||
$actor->getID(),
|
$actor->getID(),
|
||||||
ActivityUtils::resolveUri(self::getObjectType(), true),
|
ActivityUtils::resolveUri($object->getObjectType(), true),
|
||||||
$object->getID(),
|
$object->getID(),
|
||||||
common_date_iso8601($created));
|
common_date_iso8601($created));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user