mirror of
https://github.com/friendica/friendica
synced 2025-04-27 09:10:12 +00:00
Detect linked posts and add them as quote
This commit is contained in:
parent
1585f711ee
commit
f8f0dfa91a
6 changed files with 115 additions and 23 deletions
|
@ -608,9 +608,10 @@ class Item
|
|||
*
|
||||
* @param integer $UriId
|
||||
* @param integer $uid
|
||||
* @param bool $add_media
|
||||
* @return string
|
||||
*/
|
||||
public function createSharedPostByUriId(int $UriId, int $uid = 0): string
|
||||
public function createSharedPostByUriId(int $UriId, int $uid = 0, bool $add_media = false): string
|
||||
{
|
||||
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
|
||||
$shared_item = Post::selectFirst($fields, ['uri-id' => $UriId, 'uid' => [$uid, 0], 'private' => [ModelItem::PUBLIC, ModelItem::UNLISTED]]);
|
||||
|
@ -619,7 +620,7 @@ class Item
|
|||
return '';
|
||||
}
|
||||
|
||||
return $this->createSharedBlockByArray($shared_item);
|
||||
return $this->createSharedBlockByArray($shared_item, $add_media);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -627,9 +628,10 @@ class Item
|
|||
*
|
||||
* @param string $guid
|
||||
* @param integer $uid
|
||||
* @param bool $add_media
|
||||
* @return string
|
||||
*/
|
||||
public function createSharedPostByGuid(string $guid, int $uid = 0, string $host = ''): string
|
||||
public function createSharedPostByGuid(string $guid, int $uid = 0, string $host = '', bool $add_media = false): string
|
||||
{
|
||||
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
|
||||
$shared_item = Post::selectFirst($fields, ['guid' => $guid, 'uid' => [$uid, 0], 'private' => [ModelItem::PUBLIC, ModelItem::UNLISTED]]);
|
||||
|
@ -646,7 +648,7 @@ class Item
|
|||
return '';
|
||||
}
|
||||
|
||||
return $this->createSharedBlockByArray($shared_item);
|
||||
return $this->createSharedBlockByArray($shared_item, $add_media);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -678,7 +680,7 @@ class Item
|
|||
|
||||
// If it is a reshared post then reformat it to avoid display problems with two share elements
|
||||
if (Diaspora::isReshare($item['body'], false)) {
|
||||
if (!empty($shared['guid']) && ($encaspulated_share = self::createSharedPostByGuid($shared['guid']))) {
|
||||
if (!empty($shared['guid']) && ($encaspulated_share = self::createSharedPostByGuid($shared['guid'], 0, '', $add_media))) {
|
||||
$item['body'] = preg_replace("/\[share.*?\](.*)\[\/share\]/ism", $encaspulated_share, $item['body']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue