Add show_attachment_filenames field to users

This commit is contained in:
Sergey Suprunenko 2020-07-12 23:15:33 +02:00
parent 319177260a
commit 057da2dd9c
No known key found for this signature in database
GPG Key ID: 5DCA7D1BE3914F9C
14 changed files with 45 additions and 2 deletions

View File

@ -273,6 +273,7 @@ switched to a new configuration mechanism, however it was not officially removed
- Mastodon API: Support irreversible property for filters.
- Mastodon API: Add pleroma.favicon field to accounts.
- Mastodon API: Add `filename` parameter to `POST /api/v1/media` and `POST /api/v2/media`.
- Mastodon API: Add account setting for providing filename to post attachments
- Admin API: endpoints for create/update/delete OAuth Apps.
- Admin API: endpoint for status view.
- OTP: Add command to reload emoji packs

View File

@ -138,6 +138,7 @@ defmodule Pleroma.User do
field(:is_discoverable, :boolean, default: false)
field(:invisible, :boolean, default: false)
field(:allow_following_move, :boolean, default: true)
field(:show_attachment_filenames, :boolean, default: false)
field(:skip_thread_containment, :boolean, default: false)
field(:actor_type, :string, default: "Person")
field(:also_known_as, {:array, :string}, default: [])
@ -503,6 +504,7 @@ defmodule Pleroma.User do
:allow_following_move,
:background,
:show_role,
:show_attachment_filenames,
:skip_thread_containment,
:fields,
:raw_fields,

View File

@ -48,6 +48,7 @@ defmodule Pleroma.Web.AdminAPI.AccountView do
:hide_followers,
:hide_favorites,
:allow_following_move,
:show_attachment_filenames,
:show_role,
:skip_thread_containment,
:pleroma_settings_store,

View File

@ -604,6 +604,11 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
nullable: true,
description: "Opaque user settings to be saved on the backend."
},
show_attachment_filenames: %Schema{
allOf: [BooleanLike],
nullable: true,
description: "Show the attachment filenames"
},
skip_thread_containment: %Schema{
allOf: [BooleanLike],
nullable: true,
@ -642,6 +647,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
show_role: false,
default_scope: "private",
pleroma_settings_store: %{"pleroma-fe" => %{"key" => "val"}},
show_attachment_filenames: false,
skip_thread_containment: false,
allow_following_move: false,
discoverable: false,

View File

@ -48,6 +48,7 @@ defmodule Pleroma.Web.ApiSpec.MediaOperation do
},
filename: %Schema{
type: :string,
nullable: true,
description: "Filename of the media."
},
focus: %Schema{

View File

@ -76,6 +76,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
type: :boolean,
description: "whether the user is a moderator of the local instance"
},
show_attachment_filenames: %Schema{type: :boolean},
skip_thread_containment: %Schema{type: :boolean},
tags: %Schema{
type: :array,
@ -172,6 +173,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
"hide_follows_count" => false,
"is_admin" => false,
"is_moderator" => false,
"show_attachment_filenames" => false,
"skip_thread_containment" => false,
"accepts_chat_messages" => true,
"chat_token" =>

View File

@ -51,7 +51,11 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Attachment do
type: :object,
properties: %{
mime_type: %Schema{type: :string, description: "mime type of the attachment"},
filename: %Schema{type: :string, description: "filename of the attachment"}
filename: %Schema{
type: :string,
nullable: true,
description: "filename of the attachment"
}
}
}
},

View File

@ -31,6 +31,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do
"hide_follows_count" => false,
"hide_follows" => false,
"background_image" => nil,
"show_attachment_filenames" => false,
"skip_thread_containment" => false,
"hide_followers" => false,
"relationship" => %{},

View File

@ -278,6 +278,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
"showing_reblogs" => true,
"subscribing" => false
},
"show_attachment_filenames" => false,
"skip_thread_containment" => false,
"tags" => []
},

View File

@ -182,6 +182,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
:hide_followers,
:hide_follows,
:hide_favorites,
:show_attachment_filenames,
:show_role,
:skip_thread_containment,
:allow_following_move,

View File

@ -277,6 +277,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
hide_follows: user.hide_follows,
hide_favorites: user.hide_favorites,
relationship: relationship,
show_attachment_filenames: user.show_attachment_filenames,
skip_thread_containment: user.skip_thread_containment,
background_image: image_url(user.background) |> MediaProxy.url(),
accepts_chat_messages: user.accepts_chat_messages,

View File

@ -0,0 +1,9 @@
defmodule Pleroma.Repo.Migrations.AddAttachmentFilenameSettingToUsers do
use Ecto.Migration
def change do
alter table(:users) do
add(:show_attachment_filenames, :boolean, default: false)
end
end
end

View File

@ -180,6 +180,16 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
assert refresh_record(user).skip_thread_containment
end
test "updates the user's show_attachment_filenames option", %{user: user, conn: conn} do
response =
conn
|> patch("/api/v1/accounts/update_credentials", %{show_attachment_filenames: "true"})
|> json_response_and_validate_schema(200)
assert response["pleroma"]["show_attachment_filenames"]
assert refresh_record(user).show_attachment_filenames
end
test "updates the user's hide_follows status", %{conn: conn} do
conn = patch(conn, "/api/v1/accounts/update_credentials", %{hide_follows: "true"})

View File

@ -35,7 +35,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
"<script src=\"invalid-html\"></script><span>valid html</span>. a<br>b<br/>c<br >d<br />f '&<>\"",
inserted_at: ~N[2017-08-15 15:47:06.597036],
emoji: %{"karjalanpiirakka" => "/file.png"},
raw_bio: "valid html. a\nb\nc\nd\nf '&<>\""
raw_bio: "valid html. a\nb\nc\nd\nf '&<>\"",
show_attachment_filenames: true
})
expected = %{
@ -87,6 +88,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
hide_followers_count: false,
hide_follows_count: false,
relationship: %{},
show_attachment_filenames: true,
skip_thread_containment: false,
accepts_chat_messages: nil
}
@ -185,6 +187,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
hide_followers_count: false,
hide_follows_count: false,
relationship: %{},
show_attachment_filenames: false,
skip_thread_containment: false,
accepts_chat_messages: nil
}