kopia lustrzana https://github.com/nextcloud/social
delete actor on 410
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/1566/head
rodzic
17062645bb
commit
f64f753db5
|
@ -38,7 +38,7 @@ use OCP\DB\Exception as DBException;
|
|||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
class CacheActorsRequest extends CacheActorsRequestBuilder {
|
||||
public const CACHE_TTL = 60 * 24; // 1d
|
||||
public const CACHE_TTL = 60 * 24 * 10; // 10d
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -125,7 +125,7 @@ class PersonInterface extends AbstractActivityPubInterface implements IActivityP
|
|||
break;
|
||||
|
||||
case Delete::TYPE:
|
||||
$this->deleteActor($item);
|
||||
$this->delete($item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -141,14 +141,19 @@ class PersonInterface extends AbstractActivityPubInterface implements IActivityP
|
|||
}
|
||||
}
|
||||
|
||||
public function deleteActor(Person $actor): void {
|
||||
$this->actionsRequest->deleteByActor($actor->getId());
|
||||
$this->cacheActorsRequest->deleteCacheById($actor->getId());
|
||||
$this->cacheDocumentsRequest->deleteByParent($actor->getId());
|
||||
$this->requestQueueRequest->deleteByAuthor($actor->getId());
|
||||
$this->followsRequest->deleteRelatedId($actor->getId());
|
||||
|
||||
$this->deleteStreamFromActor($actor);
|
||||
public function delete(ACore $item): void {
|
||||
if (!($item instanceof Person)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->actionsRequest->deleteByActor($item->getId());
|
||||
$this->cacheActorsRequest->deleteCacheById($item->getId());
|
||||
$this->cacheDocumentsRequest->deleteByParent($item->getId());
|
||||
$this->requestQueueRequest->deleteByAuthor($item->getId());
|
||||
$this->followsRequest->deleteRelatedId($item->getId());
|
||||
|
||||
$this->deleteStreamFromActor($item);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ class AccountService {
|
|||
// delete related data
|
||||
/** @var PersonInterface $interface */
|
||||
$interface = AP::$activityPub->getInterfaceFromType(Person::TYPE);
|
||||
$interface->deleteActor($actor);
|
||||
$interface->delete($actor);
|
||||
|
||||
// broadcast delete event
|
||||
$delete = new Delete();
|
||||
|
|
|
@ -51,6 +51,7 @@ use OCA\Social\Tools\Exceptions\RequestResultNotJsonException;
|
|||
use OCA\Social\Tools\Exceptions\RequestResultSizeException;
|
||||
use OCA\Social\Tools\Exceptions\RequestServerException;
|
||||
use OCA\Social\Tools\Traits\TArrayTools;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\IURLGenerator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
@ -132,7 +133,16 @@ class CacheActorService {
|
|||
|
||||
$actor = $this->cacheActorsRequest->getFromId($id);
|
||||
} catch (CacheActorDoesNotExistException $e) {
|
||||
$object = $this->curlService->retrieveObject($id);
|
||||
try {
|
||||
$object = $this->curlService->retrieveObject($id);
|
||||
} catch (RequestContentException $e) {
|
||||
// in case of refresh but remote tells us that actor is gone, we delete it.
|
||||
if ($refresh && $e->getCode() === Http::STATUS_GONE) {
|
||||
$this->delete($this->cacheActorsRequest->getFromId($id));
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->logger->debug('object retrieved', ['id' => $id, 'object' => $object]);
|
||||
|
||||
|
@ -304,4 +314,17 @@ class CacheActorService {
|
|||
} catch (ItemUnknownException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $actor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function delete(Person $actor): void {
|
||||
try {
|
||||
$interface = AP::$activityPub->getInterfaceFromType($actor->getType());
|
||||
$interface->delete($actor);
|
||||
} catch (ItemUnknownException $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,10 +247,8 @@ class CurlService {
|
|||
$request->setProtocol($url['scheme']);
|
||||
|
||||
$result = $this->retrieveJson($request);
|
||||
|
||||
if (is_array($result)) {
|
||||
$result['_host'] = $request->getHost();
|
||||
}
|
||||
$result['_host'] = $request->getHost();
|
||||
$result['_resultCode'] = $request->getResultCode();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue