X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDiaspora.php;h=d276814f5d3e21a17055d14bfd8198c5be77ec58;hb=b065318366301f57a0a7aaf33f1429e73dfc991c;hp=02d6d270a696fd1ee468ccb14f21215387d3a8a3;hpb=24f8ee8e676abf4dd16916fd417562aca7bcbb9f;p=friendica.git diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 02d6d270a6..d276814f5d 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -1,6 +1,6 @@ t("Attachments:")."\n"; + $body .= "\n[hr]\n"; foreach ($attachments as $attachment) { $body .= "[" . $attachment['description'] . "](" . $attachment['url'] . ")\n"; } @@ -4053,4 +4053,56 @@ class Diaspora return $message; } + + public static function performReshare(int $UriId, int $uid) + { + $fields = ['uri-id', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink']; + $item = Post::selectFirst($fields, ['uri-id' => $UriId, 'uid' => [$uid, 0], 'private' => [Item::PUBLIC, Item::UNLISTED]]); + if (!DBA::isResult($item)) { + return 0; + } + + if (strpos($item['body'], '[/share]') !== false) { + $pos = strpos($item['body'], '[share'); + $post = substr($item['body'], $pos); + } else { + $post = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid']); + + if (!empty($item['title'])) { + $post .= '[h3]' . $item['title'] . "[/h3]\n"; + } + + $post .= $item['body']; + $post .= '[/share]'; + } + + $owner = User::getOwnerDataById($uid); + $author = Contact::getPublicIdByUserId($uid); + + $item = [ + 'uid' => $uid, + 'verb' => Activity::POST, + 'contact-id' => $owner['id'], + 'author-id' => $author, + 'owner-id' => $author, + 'body' => $post, + 'allow_cid' => $owner['allow_cid'], + 'allow_gid' => $owner['allow_gid'], + 'deny_cid' => $owner['deny_cid'], + 'deny_gid' => $owner['deny_gid'], + ]; + + if (!empty($item['allow_cid'] . $item['allow_gid'] . $item['deny_cid'] . $item['deny_gid'])) { + $item['private'] = Item::PRIVATE; + } elseif (DI::pConfig()->get($uid, 'system', 'unlisted')) { + $item['private'] = Item::UNLISTED; + } else { + $item['private'] = Item::PUBLIC; + } + + // Don't trigger the addons + $item['api_source'] = false; + + return Item::insert($item, true); + } }