From 1e4897866435c803ff6e6bbdbe456d8d3038ce98 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 28 Feb 2023 15:02:02 -0500 Subject: [PATCH 1/2] Use Mastodon standard edited_at field for tracking edit time --- src/Factory/Api/Mastodon/Status.php | 4 ++-- src/Module/BaseApi.php | 4 ++-- src/Object/Api/Mastodon/Status.php | 12 ++++++++++++ .../Api/Mastodon/Status/FriendicaExtension.php | 14 -------------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Factory/Api/Mastodon/Status.php b/src/Factory/Api/Mastodon/Status.php index 642c9efe83..9c1bce0268 100644 --- a/src/Factory/Api/Mastodon/Status.php +++ b/src/Factory/Api/Mastodon/Status.php @@ -289,7 +289,7 @@ class Status extends BaseFactory } $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); } @@ -355,7 +355,7 @@ class Status extends BaseFactory $attachments = []; $in_reply = []; $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); } diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index 10e64044f3..b5fc8c8499 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -221,8 +221,8 @@ class BaseApi extends BaseModule } break; case TimelineOrderByTypes::EDITED: - if (!empty($status->friendicaExtension()->editedAt())) { - self::setBoundaries(new DateTime(DateTimeFormat::utc($status->friendicaExtension()->editedAt(), DateTimeFormat::JSON))); + if (!empty($status->editedAt())) { + self::setBoundaries(new DateTime(DateTimeFormat::utc($status->editedAt(), DateTimeFormat::JSON))); } break; case TimelineOrderByTypes::RECEIVED: diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php index 5563981f13..1ce996c5d8 100644 --- a/src/Object/Api/Mastodon/Status.php +++ b/src/Object/Api/Mastodon/Status.php @@ -40,6 +40,8 @@ class Status extends BaseDataTransferObject protected $id; /** @var string|null (Datetime) */ protected $created_at; + /** @var string|null (Datetime) */ + protected $edited_at; /** @var string|null */ protected $in_reply_to_id = null; /** @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->created_at = $item['created']; + $this->edited_at = $item['edited']; if ($item['gravity'] == Item::GRAVITY_COMMENT) { $this->in_reply_to_id = (string)$item['thr-parent-id']; @@ -163,6 +166,15 @@ class Status extends BaseDataTransferObject 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 * @return FriendicaExtension diff --git a/src/Object/Api/Mastodon/Status/FriendicaExtension.php b/src/Object/Api/Mastodon/Status/FriendicaExtension.php index b6dcd5df0c..8e68f3014e 100644 --- a/src/Object/Api/Mastodon/Status/FriendicaExtension.php +++ b/src/Object/Api/Mastodon/Status/FriendicaExtension.php @@ -41,9 +41,6 @@ class FriendicaExtension extends BaseDataTransferObject /** @var string|null (Datetime) */ protected $commented_at; - /** @var string|null (Datetime) */ - protected $edited_at; - /** @var string|null (Datetime) */ protected $received_at; @@ -68,7 +65,6 @@ class FriendicaExtension extends BaseDataTransferObject string $title, ?string $changed_at, ?string $commented_at, - ?string $edited_at, ?string $received_at, int $dislikes_count, FriendicaDeliveryData $delivery_data @@ -76,7 +72,6 @@ class FriendicaExtension extends BaseDataTransferObject $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; @@ -100,15 +95,6 @@ class FriendicaExtension extends BaseDataTransferObject 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 From 63a65b6d02fe8a5bada485c5d80044a8ec5fdc6b Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 28 Feb 2023 16:10:13 -0500 Subject: [PATCH 2/2] Fix passing in correct change fields to Mastodon Status FriendicaExtension --- src/Factory/Api/Mastodon/Status.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Factory/Api/Mastodon/Status.php b/src/Factory/Api/Mastodon/Status.php index 9c1bce0268..d794247cb1 100644 --- a/src/Factory/Api/Mastodon/Status.php +++ b/src/Factory/Api/Mastodon/Status.php @@ -289,7 +289,7 @@ class Status extends BaseFactory } $delivery_data = new FriendicaDeliveryData($item['delivery_queue_count'], $item['delivery_queue_done'], $item['delivery_queue_failed']); - $friendica = new FriendicaExtension($item['title'], $item['commented'], $item['edited'], $item['received'], $counts->dislikes, $delivery_data); + $friendica = new FriendicaExtension($item['title'], $item['changed'], $item['commented'], $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); }