mirror of
https://github.com/friendica/friendica
synced 2025-04-23 07:50:12 +00:00
Avoid empty posts on Diaspora
This commit is contained in:
parent
3666742e7b
commit
c840ee82af
4 changed files with 13 additions and 9 deletions
|
@ -526,15 +526,19 @@ class Media
|
|||
* Add media attachments to the body
|
||||
*
|
||||
* @param int $uriid
|
||||
* @param string $body
|
||||
* @return string body
|
||||
*/
|
||||
public static function addAttachmentsToBody(int $uriid)
|
||||
public static function addAttachmentsToBody(int $uriid, string $body = '')
|
||||
{
|
||||
$item = Post::selectFirst(['body'], ['uri-id' => $uriid]);
|
||||
if (!DBA::isResult($item)) {
|
||||
return '';
|
||||
if (empty($body)) {
|
||||
$item = Post::selectFirst(['body'], ['uri-id' => $uriid]);
|
||||
if (!DBA::isResult($item)) {
|
||||
return '';
|
||||
}
|
||||
$body = $item['body'];
|
||||
}
|
||||
$body = preg_replace("/\s*\[attachment .*?\].*?\[\/attachment\]\s*/ism", '', $item['body']);
|
||||
$body = preg_replace("/\s*\[attachment .*?\].*?\[\/attachment\]\s*/ism", '', $body);
|
||||
|
||||
foreach (self::getByURIId($uriid, [self::IMAGE, self::AUDIO, self::VIDEO]) as $media) {
|
||||
if (Item::containsLink($body, $media['url'])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue