]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Add logging for unexpected empty published key in activity
[friendica.git] / src / Protocol / Diaspora.php
index 1daea43fd46aa1d67614469bd6d3c7d114903220..5caa6c7a151147d53b296042af66c5872db6f3c3 100644 (file)
@@ -24,7 +24,7 @@ namespace Friendica\Protocol;
 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;
@@ -2719,7 +2719,7 @@ class Diaspora
 
                /// @todo enable support for polls
                //if ($data->poll) {
-               //      foreach ($data->poll AS $poll)
+               //      foreach ($data->poll as $poll)
                //              print_r($poll);
                //      die("poll!\n");
                //}
@@ -3314,15 +3314,12 @@ class Diaspora
                $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']));
@@ -3414,7 +3411,7 @@ class Diaspora
 
                        $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";
                                }
@@ -4056,4 +4053,53 @@ 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;
+               }
+
+               return Item::insert($item, true);
+       }
 }