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\Object\Api\Mastodon\Status\Counts;
27 use Friendica\Util\DateTimeFormat;
32 * @see https://docs.joinmastodon.org/entities/status
34 class Status extends BaseEntity
38 /** @var string (Datetime) */
39 protected $created_at;
40 /** @var string|null */
41 protected $in_reply_to_id = null;
42 /** @var string|null */
43 protected $in_reply_to_account_id = null;
45 protected $sensitive = false;
47 protected $spoiler_text = "";
48 /** @var string (Enum of public, unlisted, private, direct)*/
49 protected $visibility;
50 /** @var string|null */
51 protected $language = null;
54 /** @var string|null (URL)*/
55 protected $url = null;
57 protected $replies_count = 0;
59 protected $reblogs_count = 0;
61 protected $favourites_count = 0;
63 protected $favourited = false;
65 protected $reblogged = false;
67 protected $muted = false;
69 protected $bookmarked = false;
71 protected $pinned = false;
74 /** @var Status|null */
75 protected $reblog = null;
76 /** @var Application */
77 protected $application = null;
80 /** @var Attachment */
81 protected $media_attachments = [];
83 protected $mentions = [];
87 protected $emojis = [];
89 protected $card = null;
91 protected $poll = null;
94 * Creates a status record from an item record.
97 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
99 public function __construct(array $item, Account $account, Counts $counts)
101 $this->id = (string)$item['uri-id'];
102 $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::ATOM);
104 if ($item['gravity'] == GRAVITY_COMMENT) {
105 $this->in_reply_to_id = (string)$item['thr-parent-id'];
106 $this->in_reply_to_account_id = (string)$item['parent-author-id'];
109 $this->sensitive = false;
110 $this->spoiler_text = $item['title'];
112 $visibility = ['public', 'private', 'unlisted'];
113 $this->visibility = $visibility[$item['private']];
115 $this->language = null;
116 $this->uri = $item['uri'];
117 $this->url = $item['plink'] ?? null;
118 $this->replies_count = $counts->replies;
119 $this->reblogs_count = $counts->reblogs;
120 $this->favourites_count = $counts->favourites;
121 $this->favourited = false;
122 $this->reblogged = false;
123 $this->muted = false;
124 $this->bookmarked = false;
125 $this->pinned = false;
126 $this->content = BBCode::convert($item['body'], false);
127 $this->reblog = null;
128 $this->application = null;
129 $this->account = $account->toArray();
130 $this->media_attachments = [];
131 $this->mentions = [];