[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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$other = [];
|
// The deleting user must have permission to do so, but
|
||||||
|
// it still doesn't own the notitce, so we just need to
|
||||||
foreach ($notice->getAttentionProfiles() as $to_profile) {
|
// handle things locally
|
||||||
try {
|
if (!$notice->isLocal()) {
|
||||||
$other[] = Activitypub_profile::from_profile($to_profile);
|
return true;
|
||||||
} catch (Exception $e) {
|
|
||||||
// Local user can be ignored
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$other = Activitypub_profile::from_profile_collection(
|
||||||
|
$notice->getAttentionProfiles()
|
||||||
|
);
|
||||||
|
|
||||||
if ($notice->reply_to) {
|
if ($notice->reply_to) {
|
||||||
try {
|
try {
|
||||||
$other[] = Activitypub_profile::from_profile($notice->getParent()->getProfile());
|
$parent_notice = $notice->getParent();
|
||||||
} catch (Exception $e) {
|
|
||||||
// Local user can be ignored
|
try {
|
||||||
}
|
$other[] = Activitypub_profile::from_profile($parent_notice->getProfile());
|
||||||
try {
|
} catch (Exception $e) {
|
||||||
$mentions = $notice->getParent()->getAttentionProfiles();
|
// Local user can be ignored
|
||||||
foreach ($mentions as $to_profile) {
|
|
||||||
try {
|
|
||||||
$other[] = Activitypub_profile::from_profile($to_profile);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// Local user can be ignored
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$other = array_merge($other,
|
||||||
|
Activitypub_profile::from_profile_collection(
|
||||||
|
$parent_notice->getAttentionProfiles()
|
||||||
|
));
|
||||||
} catch (NoParentNoticeException $e) {
|
} catch (NoParentNoticeException $e) {
|
||||||
// This is not a reply to something (has no parent)
|
// This is not a reply to something (has no parent)
|
||||||
} catch (NoResultException $e) {
|
} catch (NoResultException $e) {
|
||||||
|
|
|
@ -213,8 +213,19 @@ class Activitypub_inbox_handler
|
||||||
*/
|
*/
|
||||||
private function handle_delete($actor, $object)
|
private function handle_delete($actor, $object)
|
||||||
{
|
{
|
||||||
$notice = ActivityPubPlugin::grab_notice_from_url($object['object']);
|
// some moderator could already have deleted the
|
||||||
$notice->deleteAs($actor);
|
// 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(
|
$data = Activitypub_delete::delete_to_array(
|
||||||
ActivityPubPlugin::actor_uri($notice->getProfile()),
|
ActivityPubPlugin::actor_uri($notice->getProfile()),
|
||||||
$notice->getUrl()
|
Activitypub_notice::getUrl($notice)
|
||||||
);
|
);
|
||||||
$errors = [];
|
$errors = [];
|
||||||
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user