Use Mastodon standard edited_at field for tracking edit time

This commit is contained in:
Hank Grabowski 2023-02-28 15:02:02 -05:00
parent 8ce90d7b41
commit 1e48978664
4 changed files with 16 additions and 18 deletions

View file

@ -289,7 +289,7 @@ class Status extends BaseFactory
} }
$delivery_data = new FriendicaDeliveryData($item['delivery_queue_count'], $item['delivery_queue_done'], $item['delivery_queue_failed']); $delivery_data = new FriendicaDeliveryData($item['delivery_queue_count'], $item['delivery_queue_done'], $item['delivery_queue_failed']);
$friendica = new FriendicaExtension($item['title'], $item['changed'], $item['commented'], $item['edited'], $item['received'], $counts->dislikes, $delivery_data); $friendica = new FriendicaExtension($item['title'], $item['commented'], $item['edited'], $item['received'], $counts->dislikes, $delivery_data);
return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica, $quote, $poll); return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica, $quote, $poll);
} }
@ -355,7 +355,7 @@ class Status extends BaseFactory
$attachments = []; $attachments = [];
$in_reply = []; $in_reply = [];
$reshare = []; $reshare = [];
$friendica = new FriendicaExtension('', null, null, null, null, 0, new FriendicaDeliveryData(0, 0, 0)); $friendica = new FriendicaExtension('', null, null, null, 0, new FriendicaDeliveryData(0, 0, 0));
return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica); return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $in_reply, $reshare, $friendica);
} }

View file

@ -221,8 +221,8 @@ class BaseApi extends BaseModule
} }
break; break;
case TimelineOrderByTypes::EDITED: case TimelineOrderByTypes::EDITED:
if (!empty($status->friendicaExtension()->editedAt())) { if (!empty($status->editedAt())) {
self::setBoundaries(new DateTime(DateTimeFormat::utc($status->friendicaExtension()->editedAt(), DateTimeFormat::JSON))); self::setBoundaries(new DateTime(DateTimeFormat::utc($status->editedAt(), DateTimeFormat::JSON)));
} }
break; break;
case TimelineOrderByTypes::RECEIVED: case TimelineOrderByTypes::RECEIVED:

View file

@ -40,6 +40,8 @@ class Status extends BaseDataTransferObject
protected $id; protected $id;
/** @var string|null (Datetime) */ /** @var string|null (Datetime) */
protected $created_at; protected $created_at;
/** @var string|null (Datetime) */
protected $edited_at;
/** @var string|null */ /** @var string|null */
protected $in_reply_to_id = null; protected $in_reply_to_id = null;
/** @var Status|null - Fedilab extension, see issue https://github.com/friendica/friendica/issues/12672 */ /** @var Status|null - Fedilab extension, see issue https://github.com/friendica/friendica/issues/12672 */
@ -109,6 +111,7 @@ class Status extends BaseDataTransferObject
{ {
$this->id = (string)$item['uri-id']; $this->id = (string)$item['uri-id'];
$this->created_at = $item['created']; $this->created_at = $item['created'];
$this->edited_at = $item['edited'];
if ($item['gravity'] == Item::GRAVITY_COMMENT) { if ($item['gravity'] == Item::GRAVITY_COMMENT) {
$this->in_reply_to_id = (string)$item['thr-parent-id']; $this->in_reply_to_id = (string)$item['thr-parent-id'];
@ -163,6 +166,15 @@ class Status extends BaseDataTransferObject
return $this->created_at; return $this->created_at;
} }
/**
* Returns the current edited_at string or null if not set
* @return ?string
*/
public function editedAt(): ?string
{
return $this->edited_at;
}
/** /**
* Returns the Friendica Extension properties * Returns the Friendica Extension properties
* @return FriendicaExtension * @return FriendicaExtension

View file

@ -41,9 +41,6 @@ class FriendicaExtension extends BaseDataTransferObject
/** @var string|null (Datetime) */ /** @var string|null (Datetime) */
protected $commented_at; protected $commented_at;
/** @var string|null (Datetime) */
protected $edited_at;
/** @var string|null (Datetime) */ /** @var string|null (Datetime) */
protected $received_at; protected $received_at;
@ -68,7 +65,6 @@ class FriendicaExtension extends BaseDataTransferObject
string $title, string $title,
?string $changed_at, ?string $changed_at,
?string $commented_at, ?string $commented_at,
?string $edited_at,
?string $received_at, ?string $received_at,
int $dislikes_count, int $dislikes_count,
FriendicaDeliveryData $delivery_data FriendicaDeliveryData $delivery_data
@ -76,7 +72,6 @@ class FriendicaExtension extends BaseDataTransferObject
$this->title = $title; $this->title = $title;
$this->changed_at = $changed_at; $this->changed_at = $changed_at;
$this->commented_at = $commented_at; $this->commented_at = $commented_at;
$this->edited_at = $edited_at;
$this->received_at = $received_at; $this->received_at = $received_at;
$this->delivery_data = $delivery_data; $this->delivery_data = $delivery_data;
$this->dislikes_count = $dislikes_count; $this->dislikes_count = $dislikes_count;
@ -100,15 +95,6 @@ class FriendicaExtension extends BaseDataTransferObject
return $this->commented_at; 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 * Returns the current received_at string or null if not set
* @return ?string * @return ?string