Merge pull request #10659 from annando/gravity

Adding gravity to avoid notices
This commit is contained in:
Hypolite Petovan 2021-09-03 09:27:40 -04:00 committed by GitHub
commit 622c030526
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View file

@ -47,13 +47,9 @@ class Fetch extends BaseModule
$guid = $parameters['guid']; $guid = $parameters['guid'];
// Fetch the item // Fetch the item
$fields = [
'uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'received', 'app', 'location', 'coord', 'network',
'event-id', 'resource-id', 'author-link', 'author-avatar', 'author-name', 'plink', 'owner-link', 'uri-id'
];
$condition = ['origin' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid, $condition = ['origin' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid,
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'network' => [Protocol::DFRN, Protocol::DIASPORA]]; 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Post::selectFirst($fields, $condition); $item = Post::selectFirst([], $condition);
if (empty($item)) { if (empty($item)) {
$condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]]; $condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Post::selectFirst(['author-link'], $condition); $item = Post::selectFirst(['author-link'], $condition);
@ -82,7 +78,7 @@ class Fetch extends BaseModule
if ($item['gravity'] == GRAVITY_PARENT) { if ($item['gravity'] == GRAVITY_PARENT) {
$status = Diaspora::buildStatus($item, $user); $status = Diaspora::buildStatus($item, $user);
} else { } else {
$status = Diaspora::constructComment($item, $user); $status = ['type' => 'comment', 'message' => Diaspora::createCommentSignature($item)];
} }
$xml = Diaspora::buildPostXml($status["type"], $status["message"]); $xml = Diaspora::buildPostXml($status["type"], $status["message"]);

View file

@ -3614,7 +3614,7 @@ class Diaspora
* @return array|false The data for a comment * @return array|false The data for a comment
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function constructComment(array $item, array $owner) private static function constructComment(array $item, array $owner)
{ {
$cachekey = "diaspora:constructComment:".$item['guid']; $cachekey = "diaspora:constructComment:".$item['guid'];