<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Markdown;
-use Friendica\Core\Cache\Duration;
+use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
} elseif (($contact["rel"] == Contact::SHARING) || ($contact["rel"] == Contact::FRIEND)) {
// Yes, then it is fine.
return true;
- // Is it a post to a community?
- } elseif (($contact["rel"] == Contact::FOLLOWER) && in_array($importer["page-flags"], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
- // That's good
- return true;
// Is the message a global user or a comment?
} elseif (($importer["uid"] == 0) || $is_comment) {
// Messages for the global users and comments are always accepted
$datarray["object-type"] = Activity\ObjectType::IMAGE;
$datarray["post-type"] = Item::PT_IMAGE;
+ } elseif ($data->poll) {
+ $datarray["object-type"] = Activity\ObjectType::NOTE;
+ $datarray["post-type"] = Item::PT_POLL;
} else {
$datarray["object-type"] = Activity\ObjectType::NOTE;
$datarray["post-type"] = Item::PT_NOTE;
$eventdata["all_day"] = "false";
$eventdata['timezone'] = 'UTC';
- if (!$event['adjust'] && $owner['timezone']) {
- $eventdata['timezone'] = $owner['timezone'];
- }
if ($event['start']) {
- $eventdata['start'] = DateTimeFormat::convert($event['start'], "UTC", $eventdata['timezone'], $mask);
+ $eventdata['start'] = DateTimeFormat::utc($event['start'], $mask);
}
if ($event['finish'] && !$event['nofinish']) {
- $eventdata['end'] = DateTimeFormat::convert($event['finish'], "UTC", $eventdata['timezone'], $mask);
+ $eventdata['end'] = DateTimeFormat::utc($event['finish'], $mask);
}
if ($event['summary']) {
$eventdata['summary'] = html_entity_decode(BBCode::toMarkdown($event['summary']));
$attachments = Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT, Post\Media::UNKNOWN]);
if (!empty($attachments)) {
- $body .= "\n".DI::l10n()->t("Attachments:")."\n";
+ $body .= "\n[hr]\n";
foreach ($attachments as $attachment) {
$body .= "[" . $attachment['description'] . "](" . $attachment['url'] . ")\n";
}
private static function prependParentAuthorMention($body, $profile_url)
{
- $profile = Contact::getByURL($profile_url, false, ['addr', 'name', 'contact-type']);
+ $profile = Contact::getByURL($profile_url, false, ['addr', 'name']);
if (!empty($profile['addr'])
- && $profile['contact-type'] != Contact::TYPE_COMMUNITY
&& !strstr($body, $profile['addr'])
&& !strstr($body, $profile_url)
) {
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);
+ }
}