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\Util\DateTimeFormat;
30 * @see https://docs.joinmastodon.org/entities/status
32 class Status extends BaseEntity
36 /** @var string (Datetime) */
37 protected $created_at;
38 /** @var string|null */
39 protected $in_reply_to_id = null;
40 /** @var string|null */
41 protected $in_reply_to_account_id = null;
43 protected $sensitive = false;
45 protected $spoiler_text = "";
46 /** @var string (Enum of public, unlisted, private, direct)*/
47 protected $visibility;
48 /** @var string|null */
49 protected $language = null;
52 /** @var string|null (URL)*/
53 protected $url = null;
55 protected $replies_count = 0;
57 protected $reblogs_count = 0;
59 protected $favourites_count = 0;
61 protected $favourited = false;
63 protected $reblogged = false;
65 protected $muted = false;
67 protected $bookmarked = false;
69 protected $pinned = false;
72 /** @var Status|null */
73 protected $reblog = null;
74 /** @var Application */
75 protected $application = null;
78 /** @var Attachment */
79 protected $media_attachments = [];
81 protected $mentions = [];
85 protected $emojis = [];
87 protected $card = null;
89 protected $poll = null;
92 * Creates a status record from an item record.
95 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
97 public function __construct(array $item, Account $account)
99 $this->id = (string)$item['uri-id'];
100 $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::ATOM);
102 if ($item['gravity'] == GRAVITY_COMMENT) {
103 $this->in_reply_to_id = (string)$item['thr-parent-id'];
104 $this->in_reply_to_account_id = (string)$item['parent-author-id'];
107 $this->sensitive = false;
108 $this->spoiler_text = "";
110 $visibility = ['public', 'private', 'unlisted'];
111 $this->visibility = $visibility[$item['private']];
113 $this->language = null;
114 $this->uri = $item['uri'];
115 $this->url = $item['plink'] ?? null;
116 $this->replies_count = 0;
117 $this->reblogs_count = 0;
118 $this->favourites_count = 0;
119 $this->favourited = false;
120 $this->reblogged = false;
121 $this->muted = false;
122 $this->bookmarked = false;
123 $this->pinned = false;
125 $this->reblog = null;
126 $this->application = null;
127 $this->account = $account->toArray();
128 $this->media_attachments = [];
129 $this->mentions = [];