3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Object\Api\Mastodon;
24 use Friendica\BaseEntity;
25 use Friendica\Content\Text\BBCode;
26 use Friendica\Util\DateTimeFormat;
31 * @see https://docs.joinmastodon.org/entities/status
33 class Status extends BaseEntity
37 /** @var string (Datetime) */
38 protected $created_at;
39 /** @var string|null */
40 protected $in_reply_to_id = null;
41 /** @var string|null */
42 protected $in_reply_to_account_id = null;
44 protected $sensitive = false;
46 protected $spoiler_text = "";
47 /** @var string (Enum of public, unlisted, private, direct)*/
48 protected $visibility;
49 /** @var string|null */
50 protected $language = null;
53 /** @var string|null (URL)*/
54 protected $url = null;
56 protected $replies_count = 0;
58 protected $reblogs_count = 0;
60 protected $favourites_count = 0;
62 protected $favourited = false;
64 protected $reblogged = false;
66 protected $muted = false;
68 protected $bookmarked = false;
70 protected $pinned = false;
73 /** @var Status|null */
74 protected $reblog = null;
75 /** @var Application */
76 protected $application = null;
79 /** @var Attachment */
80 protected $media_attachments = [];
82 protected $mentions = [];
86 protected $emojis = [];
88 protected $card = null;
90 protected $poll = null;
93 * Creates a status record from an item record.
96 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
98 public function __construct(array $item, Account $account)
100 $this->id = (string)$item['uri-id'];
101 $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::ATOM);
103 if ($item['gravity'] == GRAVITY_COMMENT) {
104 $this->in_reply_to_id = (string)$item['thr-parent-id'];
105 $this->in_reply_to_account_id = (string)$item['parent-author-id'];
108 $this->sensitive = false;
109 $this->spoiler_text = $item['title'];
111 $visibility = ['public', 'private', 'unlisted'];
112 $this->visibility = $visibility[$item['private']];
114 $this->language = null;
115 $this->uri = $item['uri'];
116 $this->url = $item['plink'] ?? null;
117 $this->replies_count = 0;
118 $this->reblogs_count = 0;
119 $this->favourites_count = 0;
120 $this->favourited = false;
121 $this->reblogged = false;
122 $this->muted = false;
123 $this->bookmarked = false;
124 $this->pinned = false;
125 $this->content = BBCode::convert($item['body'], false);
126 $this->reblog = null;
127 $this->application = null;
128 $this->account = $account->toArray();
129 $this->media_attachments = [];
130 $this->mentions = [];