Merge pull request #10076 from annando/ap-delete

Delete ActivityPub comments
This commit is contained in:
Hypolite Petovan 2021-03-24 18:56:55 -04:00 committed by GitHub
commit 9bd92ff812
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 30 deletions

View file

@ -241,7 +241,7 @@ class Item
if ($item['uid'] == $uid) {
self::markForDeletionById($item['id'], PRIORITY_HIGH);
} elseif ($item['uid'] != 0) {
Logger::log('Wrong ownership. Not deleting item ' . $item['id']);
Logger::notice('Wrong ownership. Not deleting item', ['id' => $item['id']]);
}
}
DBA::close($items);

View file

@ -69,7 +69,7 @@ class Objects extends BaseModule
}
}
$item = Post::selectFirst(['id', 'uid', 'origin', 'author-link', 'changed', 'private', 'psid', 'gravity'],
$item = Post::selectFirst(['id', 'uid', 'origin', 'author-link', 'changed', 'private', 'psid', 'gravity', 'deleted', 'parent-uri-id'],
['uri-id' => $itemuri['id']], ['order' => ['origin' => true]]);
if (!DBA::isResult($item)) {
@ -93,8 +93,16 @@ class Objects extends BaseModule
}
}
if ($validated) {
// Valid items are original post or posted from this node (including in the case of a forum)
if (!$validated || !$item['origin'] && (parse_url($item['author-link'], PHP_URL_HOST) != parse_url(DI::baseUrl()->get(), PHP_URL_HOST))) {
$validated = ($item['origin'] || (parse_url($item['author-link'], PHP_URL_HOST) == parse_url(DI::baseUrl()->get(), PHP_URL_HOST)));
if (!$validated && $item['deleted']) {
$validated = Post::exists(['origin' => true, 'uri-id' => $item['parent-uri-id']]);
}
}
if (!$validated) {
throw new HTTPException\NotFoundException();
}

View file

@ -214,13 +214,8 @@ class Post
$pinned = DI::l10n()->t('pinned item');
}
if ($origin && ($item['gravity'] != GRAVITY_PARENT) && ($item['network'] == Protocol::ACTIVITYPUB)) {
// ActivityPub doesn't allow removal of remote comments
$delete = DI::l10n()->t('Delete locally');
} else {
// Showing the one or the other text, depending upon if we can only hide it or really delete it.
$delete = $origin ? DI::l10n()->t('Delete globally') : DI::l10n()->t('Remove locally');
}
$drop = false;
$block = false;

View file

@ -1069,6 +1069,7 @@ class Transmitter
return false;
}
if (!$item['deleted']) {
$condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
$conversation = DBA::selectFirst('conversation', ['source'], $condition);
if (!$item['origin'] && DBA::isResult($conversation)) {
@ -1091,6 +1092,7 @@ class Transmitter
}
}
}
}
$type = self::getTypeOfItem($item);
@ -1106,7 +1108,9 @@ class Transmitter
$data = [];
}
if (($item['gravity'] == GRAVITY_ACTIVITY) && ($type != 'Undo')) {
if ($type == 'Delete') {
$data['id'] = Item::newURI($item['uid'], $item['guid']) . '/' . $type;;
} elseif (($item['gravity'] == GRAVITY_ACTIVITY) && ($type != 'Undo')) {
$data['id'] = $item['uri'];
} else {
$data['id'] = $item['uri'] . '/' . $type;