I think all the notice deletion calls are event-compatible now

This means we can handle DeleteNoticeAsProfile in plugins, such as
the ActivityModeration plugin.
This commit is contained in:
Mikael Nordfeldth
2015-10-03 12:26:09 +02:00
parent 88f7bb1ed5
commit dac617d95a
9 changed files with 41 additions and 26 deletions

View File

@@ -54,13 +54,15 @@ class Deleted_notice extends Managed_DataObject
);
}
public static function addNew(Notice $notice)
public static function addNew(Notice $notice, Profile $actor=null)
{
$actor = $notice->getProfile();
if (is_null($actor)) {
$actor = $notice->getProfile();
}
if ($actor->hasRole(Profile_role::DELETED)) {
// Don't emit notices if the user is deleted
return true;
if ($notice->getProfile()->hasRole(Profile_role::DELETED)) {
// Don't emit notices if the notice author is (being) deleted
return false;
}
$act = new Activity();
@@ -80,7 +82,7 @@ class Deleted_notice extends Managed_DataObject
);
$act->actor = $actor->asActivityObject();
$act->target = new ActivityObject();
$act->target = new ActivityObject(); // We don't save the notice object, as it's supposed to be removed!
$act->target->id = $notice->getUri();
$act->objects = array(clone($act->target));