kopia lustrzana https://github.com/nextcloud/social
remove follows on deleted account
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/691/head
rodzic
3292520f2d
commit
5990c58c9c
|
@ -267,7 +267,6 @@ class FollowsRequest extends FollowsRequestBuilder {
|
|||
$qb->execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Follow $follow
|
||||
*/
|
||||
|
@ -279,6 +278,21 @@ class FollowsRequest extends FollowsRequestBuilder {
|
|||
$qb->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actorId
|
||||
*/
|
||||
public function deleteRelatedId(string $actorId) {
|
||||
$qb = $this->getFollowsDeleteSql();
|
||||
$this->limitToActorId($qb, $actorId);
|
||||
|
||||
$qb->execute();
|
||||
|
||||
$qb = $this->getFollowsDeleteSql();
|
||||
$this->limitToFollowId($qb, $actorId);
|
||||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -65,37 +65,28 @@ class DeleteInterface implements IActivityPubInterface {
|
|||
$item->checkOrigin($item->getId());
|
||||
|
||||
if (!$item->hasObject()) {
|
||||
|
||||
if ($item->getObjectId() !== '') {
|
||||
$item->checkOrigin($item->getObjectId());
|
||||
|
||||
// TODO: migrate to activity() !!
|
||||
$types = ['Note', 'Person'];
|
||||
foreach ($types as $type) {
|
||||
try {
|
||||
$item->checkOrigin($item->getObjectId());
|
||||
|
||||
$interface = AP::$activityPub->getInterfaceFromType($type);
|
||||
$object = $interface->getItemById($item->getObjectId());
|
||||
$interface->delete($object);
|
||||
|
||||
return;
|
||||
} catch (InvalidOriginException $e) {
|
||||
} catch (ItemNotFoundException $e) {
|
||||
} catch (ItemUnknownException $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$object = $item->getObject();
|
||||
try {
|
||||
$item->checkOrigin($object->getId());
|
||||
// FIXME: needed ? better use activity()
|
||||
// $interface = AP::$activityPub->getInterfaceForItem($object);
|
||||
// $interface->delete($object);
|
||||
} catch (InvalidOriginException $e) {
|
||||
$interface = AP::$activityPub->getInterfaceForItem($object);
|
||||
$interface->activity($item, $object);
|
||||
} catch (ItemUnknownException $e) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace OCA\Social\Interfaces\Actor;
|
|||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Db\CacheActorsRequest;
|
||||
use OCA\Social\Db\FollowsRequest;
|
||||
use OCA\Social\Db\StreamRequest;
|
||||
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
|
||||
use OCA\Social\Exceptions\InvalidOriginException;
|
||||
|
@ -63,6 +64,9 @@ class PersonInterface implements IActivityPubInterface {
|
|||
/** @var StreamRequest */
|
||||
private $streamRequest;
|
||||
|
||||
/** @var FollowsRequest */
|
||||
private $followsRequest;
|
||||
|
||||
/** @var ActorService */
|
||||
private $actorService;
|
||||
|
||||
|
@ -78,16 +82,19 @@ class PersonInterface implements IActivityPubInterface {
|
|||
*
|
||||
* @param CacheActorsRequest $cacheActorsRequest
|
||||
* @param StreamRequest $streamRequest
|
||||
* @param FollowsRequest $followsRequest
|
||||
* @param ActorService $actorService
|
||||
* @param ConfigService $configService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
CacheActorsRequest $cacheActorsRequest, StreamRequest $streamRequest,
|
||||
ActorService $actorService, ConfigService $configService, MiscService $miscService
|
||||
FollowsRequest $followsRequest, ActorService $actorService, ConfigService $configService,
|
||||
MiscService $miscService
|
||||
) {
|
||||
$this->cacheActorsRequest = $cacheActorsRequest;
|
||||
$this->streamRequest = $streamRequest;
|
||||
$this->followsRequest = $followsRequest;
|
||||
$this->actorService = $actorService;
|
||||
$this->configService = $configService;
|
||||
$this->miscService = $miscService;
|
||||
|
@ -180,6 +187,7 @@ class PersonInterface implements IActivityPubInterface {
|
|||
/** @var Person $item */
|
||||
$this->cacheActorsRequest->deleteFromId($item->getId());
|
||||
$this->streamRequest->deleteByAuthor($item->getId());
|
||||
$this->followsRequest->deleteRelatedId($item->getId());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ use OCA\Social\Exceptions\StreamNotFoundException;
|
|||
use OCA\Social\Interfaces\IActivityPubInterface;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Create;
|
||||
use OCA\Social\Model\ActivityPub\Activity\Delete;
|
||||
use OCA\Social\Model\ActivityPub\Object\Note;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\CurlService;
|
||||
|
@ -140,6 +141,11 @@ class NoteInterface implements IActivityPubInterface {
|
|||
$item->setActivityId($activity->getId());
|
||||
$this->save($item);
|
||||
}
|
||||
|
||||
if ($activity->getType() === Delete::TYPE) {
|
||||
$activity->checkOrigin($item->getId());
|
||||
$this->delete($item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,12 +173,8 @@ class NoteInterface implements IActivityPubInterface {
|
|||
|
||||
/**
|
||||
* @param ACore $item
|
||||
*
|
||||
* @throws InvalidOriginException
|
||||
*/
|
||||
public function delete(ACore $item) {
|
||||
$item->checkOrigin(($item->getId()));
|
||||
|
||||
/** @var Note $item */
|
||||
$this->streamRequest->deleteStreamById($item->getId(), Note::TYPE);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue