mirror of
https://github.com/friendica/friendica
synced 2025-04-25 12:30:11 +00:00
Add additional Mastodon timeline sorting date types and data to output
This commit is contained in:
parent
1adb23d8fd
commit
1f6578229e
6 changed files with 138 additions and 33 deletions
|
@ -38,7 +38,7 @@ class Status extends BaseDataTransferObject
|
|||
{
|
||||
/** @var string */
|
||||
protected $id;
|
||||
/** @var string (Datetime) */
|
||||
/** @var string|null (Datetime) */
|
||||
protected $created_at;
|
||||
/** @var string|null */
|
||||
protected $in_reply_to_id = null;
|
||||
|
@ -107,8 +107,8 @@ class Status extends BaseDataTransferObject
|
|||
*/
|
||||
public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null)
|
||||
{
|
||||
$this->id = (string)$item['uri-id'];
|
||||
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
|
||||
$this->id = (string)$item['uri-id'];
|
||||
$this->created_at = $item['created'];
|
||||
|
||||
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
|
||||
$this->in_reply_to_id = (string)$item['thr-parent-id'];
|
||||
|
@ -155,18 +155,21 @@ class Status extends BaseDataTransferObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the current created_at DateTime as an integer timestamp
|
||||
* @return \DateTime
|
||||
* @throws \Exception
|
||||
* Returns the current created_at string or null if not set
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function createdAtTimestamp(): \DateTime
|
||||
public function createdAt(): ?string
|
||||
{
|
||||
$result = new \DateTime($this->created_at);
|
||||
if (!$result) {
|
||||
throw new \Exception('Unknown date-time format');
|
||||
}
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
return $result;
|
||||
/**
|
||||
* Returns the Friendica Extension properties
|
||||
* @return FriendicaExtension
|
||||
*/
|
||||
public function friendicaExtension(): FriendicaExtension
|
||||
{
|
||||
return $this->friendica;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,18 @@ class FriendicaExtension extends BaseDataTransferObject
|
|||
/** @var string */
|
||||
protected $title;
|
||||
|
||||
/** @var string|null (Datetime) */
|
||||
protected $changed_at;
|
||||
|
||||
/** @var string|null (Datetime) */
|
||||
protected $commented_at;
|
||||
|
||||
/** @var string|null (Datetime) */
|
||||
protected $edited_at;
|
||||
|
||||
/** @var string|null (Datetime) */
|
||||
protected $received_at;
|
||||
|
||||
/** @var FriendicaDeliveryData */
|
||||
protected $delivery_data;
|
||||
/** @var int */
|
||||
|
@ -47,10 +59,52 @@ class FriendicaExtension extends BaseDataTransferObject
|
|||
* @param int $dislikes_count
|
||||
* @param FriendicaDeliveryData $delivery_data
|
||||
*/
|
||||
public function __construct(string $title, int $dislikes_count, FriendicaDeliveryData $delivery_data)
|
||||
public function __construct(string $title, ?string $changed_at, ?string $commented_at, ?string $edited_at, ?string $received_at,
|
||||
int $dislikes_count, FriendicaDeliveryData $delivery_data)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->changed_at = $changed_at;
|
||||
$this->commented_at = $commented_at;
|
||||
$this->edited_at = $edited_at;
|
||||
$this->received_at = $received_at;
|
||||
$this->delivery_data = $delivery_data;
|
||||
$this->dislikes_count = $dislikes_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current changed_at string or null if not set
|
||||
* @return ?string
|
||||
*/
|
||||
public function changedAt(): ?string
|
||||
{
|
||||
return $this->changed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current commented_at string or null if not set
|
||||
* @return ?string
|
||||
*/
|
||||
public function commentedAt(): ?string
|
||||
{
|
||||
return $this->commented_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current edited_at string or null if not set
|
||||
* @return ?string
|
||||
*/
|
||||
public function editedAt(): ?string
|
||||
{
|
||||
return $this->edited_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current received_at string or null if not set
|
||||
* @return ?string
|
||||
*/
|
||||
public function receivedAt(): ?string
|
||||
{
|
||||
return $this->received_at;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,16 @@ namespace Friendica\Object\Api\Mastodon;
|
|||
*/
|
||||
abstract class TimelineOrderByTypes
|
||||
{
|
||||
const ID = 'id';
|
||||
const CREATED = 'created';
|
||||
const CHANGED = 'changed';
|
||||
|
||||
const CREATED = 'created';
|
||||
|
||||
const COMMENTED = 'commented';
|
||||
|
||||
const EDITED = 'edited';
|
||||
|
||||
const ID = 'id';
|
||||
|
||||
const RECEIVED = 'received';
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue