Removing unused functions, added (deactivated) attachments

This commit is contained in:
Michael 2021-11-23 21:54:19 +00:00
parent 0c3e491410
commit 07c2f36946
6 changed files with 264 additions and 752 deletions

View file

@ -0,0 +1,72 @@
<?php
/**
* @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Object\Api\Twitter;
use Friendica\BaseDataTransferObject;
/**
* Class Attachment
*
*
*/
class Attachment extends BaseDataTransferObject
{
/** @var string */
protected $url;
/** @var string */
protected $mimetype;
/** @var int */
protected $size;
/**
* Creates an Attachment entity array
*
* @param array $attachment
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(array $media)
{
$this->url = $media['url'];
$this->mimetype = $media['mimetype'];
$this->size = $media['size'];
}
/**
* Returns the current entity as an array
*
* @return array
*/
public function toArray(): array
{
$status = parent::toArray();
if (empty($status['mimetype'])) {
unset($status['mimetype']);
}
if (empty($status['size'])) {
unset($status['size']);
}
return $status;
}
}

View file

@ -34,22 +34,32 @@ use Friendica\Util\DateTimeFormat;
*/
class Status extends BaseDataTransferObject
{
/** @var int */
protected $id;
/** @var string */
protected $id_str;
protected $text;
/** @var bool */
protected $truncated;
/** @var string (Datetime) */
protected $created_at;
/** @var int|null */
protected $in_reply_to_status_id = null;
/** @var string|null */
protected $in_reply_to_status_id_str = null;
/** @var string */
protected $source;
/** @var int */
protected $id;
/** @var string */
protected $id_str;
/** @var int|null */
protected $in_reply_to_user_id = null;
/** @var string|null */
protected $in_reply_to_user_id_str = null;
/** @var string|null */
protected $in_reply_to_screen_name = null;
/** @var array|null */
protected $geo;
/** @var bool */
protected $favorited = false;
/** @var User */
protected $user;
/** @var User */
@ -57,34 +67,27 @@ class Status extends BaseDataTransferObject
/** @var User */
protected $friendica_owner;
/** @var bool */
protected $favorited = false;
protected $friendica_private;
/** @var string */
protected $statusnet_html;
/** @var int */
protected $statusnet_conversation_id;
/** @var string */
protected $external_url;
/** @var array */
protected $friendica_activities;
/** @var string */
protected $friendica_title;
/** @var string */
protected $friendica_html;
/** @var int */
protected $friendica_comments;
/** @var Status|null */
protected $retweeted_status = null;
/** @var Status|null */
protected $quoted_status = null;
/** @var string */
protected $text;
/** @var string */
protected $statusnet_html;
/** @var string */
protected $friendica_html;
/** @var string */
protected $friendica_title;
/** @var bool */
protected $truncated;
/** @var int */
protected $friendica_comments;
/** @var string */
protected $source;
/** @var string */
protected $external_url;
/** @var int */
protected $statusnet_conversation_id;
/** @var bool */
protected $friendica_private;
protected $geo;
/** @var array */
protected $friendica_activities;
protected $attachments;
/** @var array */
protected $entities;
/** @var array */
@ -96,7 +99,7 @@ class Status extends BaseDataTransferObject
* @param array $item
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(string $text, array $item, User $author, User $owner, array $retweeted, array $quoted, array $geo, array $friendica_activities, array $entities, int $friendica_comments)
public function __construct(string $text, array $item, User $author, User $owner, array $retweeted, array $quoted, array $geo, array $friendica_activities, array $entities, array $attachments, int $friendica_comments)
{
$this->id = (int)$item['id'];
$this->id_str = (string)$item['id'];
@ -129,6 +132,7 @@ class Status extends BaseDataTransferObject
$this->source = $item['app'] ?: 'web';
$this->geo = $geo;
$this->friendica_activities = $friendica_activities;
$this->attachments = $attachments;
$this->entities = $entities;
$this->extended_entities = $entities;
@ -156,6 +160,10 @@ class Status extends BaseDataTransferObject
unset($status['quoted_status']);
}
if (empty($status['geo'])) {
$status['geo'] = null;
}
return $status;
}
}