From 739ed14f54eea3bf6e5ddabdf3fa7f60b9618aff Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Fri, 9 Dec 2022 20:59:26 +0000 Subject: [PATCH] Revert "mandate published on notes" This reverts commit e49b583147748be73062acc92ea510f6f55a503a. --- CHANGELOG.md | 1 - lib/mix/tasks/pleroma/search/meilisearch.ex | 3 +- .../article_note_page_validator.ex | 2 +- .../mastodon/note-without-published.json | 44 ------------------- .../article_note_page_validator_test.exs | 7 --- 5 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 test/fixtures/mastodon/note-without-published.json diff --git a/CHANGELOG.md b/CHANGELOG.md index c0aa002a1..eef3c53b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Follow/Block/Mute imports now spin off into *n* tasks to avoid the oban timeout - Transient activities recieved from remote servers are no longer persisted in the database - Overhauled static-fe view for logged-out users -- `published` is now a mandatory field in Note objects ## Removed - FollowBotPolicy diff --git a/lib/mix/tasks/pleroma/search/meilisearch.ex b/lib/mix/tasks/pleroma/search/meilisearch.ex index caeeb58d5..27a31afcf 100644 --- a/lib/mix/tasks/pleroma/search/meilisearch.ex +++ b/lib/mix/tasks/pleroma/search/meilisearch.ex @@ -60,8 +60,7 @@ def run(["index"]) do where: fragment("data->>'type' = 'Note'") and (fragment("data->'to' \\? ?", ^Pleroma.Constants.as_public()) or - fragment("data->'cc' \\? ?", ^Pleroma.Constants.as_public())) and - fragment("data->>'published' IS NOT NULL"), + fragment("data->'cc' \\? ?", ^Pleroma.Constants.as_public())), order_by: [desc: fragment("data->'published'")] ) diff --git a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex index 0967f557a..0d45421e2 100644 --- a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex @@ -172,7 +172,7 @@ def changeset(struct, data) do defp validate_data(data_cng) do data_cng |> validate_inclusion(:type, ["Article", "Note", "Page"]) - |> validate_required([:id, :actor, :attributedTo, :type, :context, :published]) + |> validate_required([:id, :actor, :attributedTo, :type, :context]) |> CommonValidations.validate_any_presence([:cc, :to]) |> CommonValidations.validate_fields_match([:actor, :attributedTo]) |> CommonValidations.validate_actor_presence() diff --git a/test/fixtures/mastodon/note-without-published.json b/test/fixtures/mastodon/note-without-published.json deleted file mode 100644 index c721ecef5..000000000 --- a/test/fixtures/mastodon/note-without-published.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "@context" : [ - "https://www.w3.org/ns/activitystreams", - "https://w3id.org/security/v1", - { - "Emoji" : "toot:Emoji", - "Hashtag" : "as:Hashtag", - "atomUri" : "ostatus:atomUri", - "conversation" : "ostatus:conversation", - "inReplyToAtomUri" : "ostatus:inReplyToAtomUri", - "manuallyApprovesFollowers" : "as:manuallyApprovesFollowers", - "movedTo" : "as:movedTo", - "ostatus" : "http://ostatus.org#", - "sensitive" : "as:sensitive", - "toot" : "http://joinmastodon.org/ns#" - } - ], - "atomUri" : "http://mastodon.example.org/users/admin/statuses/99541947525187367", - "attachment" : [ - { - "mediaType" : "image/jpeg", - "name" : null, - "type" : "Document", - "url" : "http://mastodon.example.org/system/media_attachments/files/000/000/002/original/334ce029e7bfb920.jpg" - } - ], - "attributedTo" : "http://mastodon.example.org/users/admin", - "cc" : [ - "http://mastodon.example.org/users/admin/followers" - ], - "content" : "

yeah.

", - "conversation" : "tag:mastodon.example.org,2018-02-17:objectId=59:objectType=Conversation", - "id" : "http://mastodon.example.org/users/admin/statuses/99541947525187367", - "inReplyTo" : null, - "inReplyToAtomUri" : null, - "sensitive" : false, - "summary" : null, - "tag" : [], - "to" : [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "type" : "Note", - "url" : "http://mastodon.example.org/@admin/99541947525187367" -} diff --git a/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs b/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs index 0ddc3c76d..5b95ebc51 100644 --- a/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs +++ b/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs @@ -28,7 +28,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest "to" => [user.follower_address], "cc" => [], "content" => "Hellow this is content.", - "published" => "2021-01-01T00:00:00Z", "context" => "xxx", "summary" => "a post" } @@ -66,12 +65,6 @@ test "a note with a remote replies collection should validate", _ do ArticleNotePageValidator.cast_and_validate(note) end - test "a note without a published field should not validate", _ do - insert(:user, %{ap_id: "http://mastodon.example.org/users/admin"}) - note = Jason.decode!(File.read!("test/fixtures/mastodon/note-without-published.json")) - %{valid?: false} = ArticleNotePageValidator.cast_and_validate(note) - end - test "a note with an attachment should work", _ do insert(:user, %{ap_id: "https://owncast.localhost.localdomain/federation/user/streamer"})