[ActivityPub] Ensuring notice deletion
ActivityPubPlugin: - Minor onDeleteOwnNotice rewrite Activitypub_inbox_handler: - Add deletion check to incoming notice Activitypub_postman: - Call the correct getUrl function
This commit is contained in:
parent
87423a0191
commit
9de1c34bc0
@ -743,30 +743,31 @@ class ActivityPubPlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
$other = [];
|
||||
|
||||
foreach ($notice->getAttentionProfiles() as $to_profile) {
|
||||
try {
|
||||
$other[] = Activitypub_profile::from_profile($to_profile);
|
||||
} catch (Exception $e) {
|
||||
// Local user can be ignored
|
||||
}
|
||||
// The deleting user must have permission to do so, but
|
||||
// it still doesn't own the notitce, so we just need to
|
||||
// handle things locally
|
||||
if (!$notice->isLocal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$other = Activitypub_profile::from_profile_collection(
|
||||
$notice->getAttentionProfiles()
|
||||
);
|
||||
|
||||
if ($notice->reply_to) {
|
||||
try {
|
||||
$other[] = Activitypub_profile::from_profile($notice->getParent()->getProfile());
|
||||
} catch (Exception $e) {
|
||||
// Local user can be ignored
|
||||
}
|
||||
try {
|
||||
$mentions = $notice->getParent()->getAttentionProfiles();
|
||||
foreach ($mentions as $to_profile) {
|
||||
try {
|
||||
$other[] = Activitypub_profile::from_profile($to_profile);
|
||||
} catch (Exception $e) {
|
||||
// Local user can be ignored
|
||||
}
|
||||
$parent_notice = $notice->getParent();
|
||||
|
||||
try {
|
||||
$other[] = Activitypub_profile::from_profile($parent_notice->getProfile());
|
||||
} catch (Exception $e) {
|
||||
// Local user can be ignored
|
||||
}
|
||||
|
||||
$other = array_merge($other,
|
||||
Activitypub_profile::from_profile_collection(
|
||||
$parent_notice->getAttentionProfiles()
|
||||
));
|
||||
} catch (NoParentNoticeException $e) {
|
||||
// This is not a reply to something (has no parent)
|
||||
} catch (NoResultException $e) {
|
||||
|
@ -213,8 +213,19 @@ class Activitypub_inbox_handler
|
||||
*/
|
||||
private function handle_delete($actor, $object)
|
||||
{
|
||||
$notice = ActivityPubPlugin::grab_notice_from_url($object['object']);
|
||||
$notice->deleteAs($actor);
|
||||
// some moderator could already have deleted the
|
||||
// notice, so we test it first
|
||||
try {
|
||||
$found = Deleted_notice::getByUri($object);
|
||||
$deleted = ($found instanceof Deleted_notice);
|
||||
} catch (NoResultException $e) {
|
||||
$deleted = false;
|
||||
}
|
||||
|
||||
if (!$deleted) {
|
||||
$notice = ActivityPubPlugin::grab_notice_from_url($object);
|
||||
$notice->deleteAs($actor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -350,7 +350,7 @@ class Activitypub_postman
|
||||
{
|
||||
$data = Activitypub_delete::delete_to_array(
|
||||
ActivityPubPlugin::actor_uri($notice->getProfile()),
|
||||
$notice->getUrl()
|
||||
Activitypub_notice::getUrl($notice)
|
||||
);
|
||||
$errors = [];
|
||||
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
||||
|
Loading…
Reference in New Issue
Block a user