$body = $item['body'];
}
- if (empty($item['quote-uri-id'])) {
+ if (empty($item['quote-uri-id']) || ($item['quote-uri-id'] == $item['uri-id'])) {
return $body;
}
*/
public function getSharedPost(array $item, array $fields = []): array
{
- if (!empty($item['quote-uri-id'])) {
+ if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
$shared = Post::selectFirst($fields, ['uri-id' => $item['quote-uri-id'], 'uid' => [0, $item['uid'] ?? 0]]);
if (is_array($shared)) {
return [
return $attributes;
}
- if (!empty($item['quote-uri-id'])) {
+ if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
$shared = Post::selectFirst(['author-name', 'author-link', 'author-avatar', 'plink', 'created', 'guid', 'uri', 'body'], ['uri-id' => $item['quote-uri-id']]);
if (!empty($shared)) {
return [
$post['text'] = Post\Media::removeFromBody($post['text']);
$images = Post\Media::getByURIId($item['uri-id'], [Post\Media::IMAGE]);
- if (!empty($item['quote-uri-id'])) {
+ if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
$images = array_merge($images, Post\Media::getByURIId($item['quote-uri-id'], [Post\Media::IMAGE]));
}
foreach ($images as $image) {
// Look for audio or video links
$media = Post\Media::getByURIId($item['uri-id'], [Post\Media::AUDIO, Post\Media::VIDEO]);
- if (!empty($item['quote-uri-id'])) {
+ if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
$media = array_merge($media, Post\Media::getByURIId($item['quote-uri-id'], [Post\Media::AUDIO, Post\Media::VIDEO]));
}
}
}
+ if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] == $item['uri-id'])) {
+ Logger::info('Quote-Uri-Id is identical to Uri-Id', ['uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
+ unset($item['quote-uri-id']);
+ }
+
if (!empty($item['quote-uri-id'])) {
$item['raw-body'] = BBCode::removeSharedData($item['raw-body']);
$item['body'] = BBCode::removeSharedData($item['body']);
$item['body'] = BBCode::removeSharedData($item['body']);
} elseif (empty($shared_item['uri-id']) && empty($item['quote-uri-id']) && ($item['network'] != Protocol::DIASPORA)) {
$media = Post\Media::getByURIId($item['uri-id'], [Post\Media::ACTIVITY]);
- if (!empty($media)) {
+ if (!empty($media) && ($media[0]['media-uri-id'] != $item['uri-id'])) {
$shared_item = Post::selectFirst($fields, ['uri-id' => $media[0]['media-uri-id'], 'uid' => [$item['uid'], 0]]);
if (empty($shared_item['uri-id'])) {
$shared_item = Post::selectFirst($fields, ['plink' => $media[0]['url'], 'uid' => [$item['uid'], 0]]);
return $media;
}
+ if ($item['uri-id'] == $media['uri-id']) {
+ Logger::info('Media-Uri-Id is identical to Uri-Id', ['uri-id' => $media['uri-id']]);
+ return $media;
+ }
+
if (
!empty($item['plink']) && Strings::compareLink($item['plink'], $media['url']) &&
parse_url($item['plink'], PHP_URL_HOST) != parse_url($item['uri'], PHP_URL_HOST)
*/
private static function checkQuoted(array $item, array $contacts): bool
{
- if (empty($item['quote-uri-id'])) {
+ if (empty($item['quote-uri-id']) || ($item['quote-uri-id'] == $item['uri-id'])) {
return false;
}
$condition = ['uri-id' => $item['quote-uri-id'], 'uid' => $item['uid'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => [item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]];
$body = BBCode::setMentionsToNicknames($body);
- if (!empty($item['quote-uri-id'])) {
+ if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
if (Post::exists(['uri-id' => $item['quote-uri-id'], 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN]])) {
$real_quote = true;
$data['quoteUrl'] = $item['quote-uri'];
if (!empty($language)) {
$richbody = BBCode::setMentionsToNicknames($item['body'] ?? '');
$richbody = Post\Media::removeFromEndOfBody($richbody);
- if (!empty($item['quote-uri-id'])) {
+ if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
if ($real_quote) {
$richbody = DI::contentItem()->addShareLink($richbody, $item['quote-uri-id']);
} else {
$data['contentMap'][$language] = BBCode::convertForUriId($item['uri-id'], $richbody, BBCode::EXTERNAL);
}
- if (!empty($item['quote-uri-id'])) {
+ if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
$source = DI::contentItem()->addSharedPost($item, $item['body']);
} else {
$source = $item['body'];