+ /**
+ * Checks if the current action is a deletion command of a account removal activity
+ * For Diaspora and ActivityPub we don't need to send single item deletion calls.
+ * These protocols do have a dedicated command for deleting a whole account.
+ *
+ * @param string $cmd Notifier command
+ * @param array $owner Sender of the post
+ * @param string $network Receiver network
+ * @return bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ private static function isRemovalActivity($cmd, $owner, $network)
+ {
+ return ($cmd == Delivery::DELETION) && $owner['account_removed'] && in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DIASPORA]);
+ }
+
+ /**
+ * @param int $self_user_id
+ * @param int $priority The priority the Notifier queue item was created with
+ * @param string $created The date the Notifier queue item was created on
+ * @return bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ private static function notifySelfRemoval($self_user_id, $priority, $created)
+ {
+ $owner = User::getOwnerDataById($self_user_id);
+ if (!$owner) {
+ return false;
+ }
+
+ $contacts_stmt = DBA::select('contact', [], ['self' => false, 'uid' => $self_user_id]);
+ if (!DBA::isResult($contacts_stmt)) {
+ return false;
+ }
+
+ while($contact = DBA::fetch($contacts_stmt)) {
+ Contact::terminateFriendship($owner, $contact, true);
+ }
+ DBA::close($contacts_stmt);
+
+ $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser(0);
+ foreach ($inboxes as $inbox) {
+ Logger::log('Account removal for user ' . $self_user_id . ' to ' . $inbox .' via ActivityPub', Logger::DEBUG);
+ Worker::add(['priority' => PRIORITY_NEGLIGIBLE, 'created' => $created, 'dont_fork' => true],
+ 'APDelivery', Delivery::REMOVAL, '', $inbox, $self_user_id);
+ }
+
+ return true;
+ }
+
+ /**
+ * @param string $cmd
+ * @param array $target_item
+ * @param array $parent
+ * @param int $priority The priority the Notifier queue item was created with
+ * @param string $created The date the Notifier queue item was created on
+ * @return int The number of delivery tasks created
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ private static function activityPubDelivery($cmd, array $target_item, array $parent, $priority, $created, $owner)