[ActivityPub] Handle DELETE-Person activity

ActivityPubPlugin:
- update grab_notice_from_url to make online grab optional
- subscribe events of user and profile deletion
- bump minor version number

Activitypub_inbox_handler:
- separate handle_delete for delete-note and delete-person

Activitypub_postman:
- add delete-person logic

Activitypub_delete:
- update validation method to check for the "Person" type
- update to_array method to target the activity
This commit is contained in:
tenma
2019-08-27 15:37:01 +01:00
committed by Diogo Cordeiro
parent f79cd8cee3
commit c06182c38f
4 changed files with 141 additions and 32 deletions

View File

@@ -226,18 +226,54 @@ class Activitypub_inbox_handler
$object = $object['id'];
}
// Already deleted? (By some admin, perhaps?)
// profile deletion ?
$aprofile = Activitypub_explorer::get_aprofile_by_url($object);
if ($aprofile instanceof Activitypub_profile) {
$this->handle_delete_profile($aprofile);
return;
}
// note deletion ?
try {
$found = Deleted_notice::getByUri($object);
$deleted = ($found instanceof Deleted_notice);
} catch (NoResultException $e) {
$deleted = false;
$notice = ActivityPubPlugin::grab_notice_from_url($object, false);
if ($notice instanceof Notice) {
$this->handle_delete_note($notice);
}
return;
} catch (Exception $e) {
// either already deleted or not a notice at all
// nothing to do..
}
if (!$deleted) {
$notice = ActivityPubPlugin::grab_notice_from_url($object);
$notice->deleteAs($this->actor);
}
common_log(LOG_INFO, "Ignoring Delete activity, nothing that we can/need to handle.");
}
/**
* Handles a Delete-Profile Activity.
*
* Note that the actual ap_profile is deleted during the ProfileDeleteRelated event,
* subscribed by ActivityPubPlugin.
*
* @param Activitypub_profile $aprofile remote user being deleted
* @return void
* @author Bruno Casteleiro <brunoccast@fc.up.pt>
*/
private function handle_delete_profile(Activitypub_profile $aprofile): void
{
$profile = $aprofile->local_profile();
$profile->delete();
}
/**
* Handles a Delete-Note Activity.
*
* @param Notice $note remote note being deleted
* @return void
* @author Bruno Casteleiro <brunoccast@fc.up.pt>
*/
private function handle_delete_note(Notice $note): void
{
$note->deleteAs($this->actor);
}
/**