Browse Source

Mastodon API: Add `pleroma.thread_muted` to Status entity

Needed for pleroma-fe!941
tags/v1.1.4
rinpatch 4 years ago
parent
commit
3face45467
4 changed files with 24 additions and 2 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -0
      docs/api/differences_in_mastoapi_responses.md
  3. +2
    -1
      lib/pleroma/web/mastodon_api/views/status_view.ex
  4. +20
    -1
      test/web/mastodon_api/views/status_view_test.exs

+ 1
- 0
CHANGELOG.md View File

@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **Breaking:** `/api/pleroma/notifications/read` is moved to `/api/v1/pleroma/notifications/read` and now supports `max_id` and responds with Mastodon API entities.
- Configuration: OpenGraph and TwitterCard providers enabled by default
- Configuration: Filter.AnonymizeFilename added ability to retain file extension with custom text
- Mastodon API: `pleroma.thread_muted` key in the Status entity
- Federation: Return 403 errors when trying to request pages from a user's follower/following collections if they have `hide_followers`/`hide_follows` set
- NodeInfo: Return `skipThreadContainment` in `metadata` for the `skip_thread_containment` option
- NodeInfo: Return `mailerEnabled` in `metadata`


+ 1
- 0
docs/api/differences_in_mastoapi_responses.md View File

@@ -26,6 +26,7 @@ Has these additional fields under the `pleroma` object:
- `content`: a map consisting of alternate representations of the `content` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`
- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`
- `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire
- `thread_muted`: true if the thread the post belongs to is muted

## Attachments



+ 2
- 1
lib/pleroma/web/mastodon_api/views/status_view.ex View File

@@ -299,7 +299,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
content: %{"text/plain" => content_plaintext},
spoiler_text: %{"text/plain" => summary_plaintext},
expires_at: expires_at,
direct_conversation_id: direct_conversation_id
direct_conversation_id: direct_conversation_id,
thread_muted: thread_muted?
}
}
end


+ 20
- 1
test/web/mastodon_api/views/status_view_test.exs View File

@@ -150,7 +150,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
content: %{"text/plain" => HtmlSanitizeEx.strip_tags(object_data["content"])},
spoiler_text: %{"text/plain" => HtmlSanitizeEx.strip_tags(object_data["summary"])},
expires_at: nil,
direct_conversation_id: nil
direct_conversation_id: nil,
thread_muted: false
}
}

@@ -173,6 +174,24 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
assert status.muted == true
end

test "tells if the message is thread muted" do
user = insert(:user)
other_user = insert(:user)

{:ok, user} = User.mute(user, other_user)

{:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"})
status = StatusView.render("status.json", %{activity: activity, for: user})

assert status.pleroma.thread_muted == false

{:ok, activity} = CommonAPI.add_mute(user, activity)

status = StatusView.render("status.json", %{activity: activity, for: user})

assert status.pleroma.thread_muted == true
end

test "tells if the status is bookmarked" do
user = insert(:user)



Loading…
Cancel
Save