X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDiaspora.php;h=d276814f5d3e21a17055d14bfd8198c5be77ec58;hb=dbd6d10536ddc476307e82381b3b7950c38aa03d;hp=84f0c6de8218b31d66bf874efbf822dbea60a44e;hpb=6f290607de7f10cea7429aacd0b394fd3f4c4e69;p=friendica.git diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 84f0c6de82..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); + } }