Browse Source

Merge branch 'fix-all-custom-fields-deleted' into 'develop'

Fix not to use unupdated attachments when all fields are deleted

See merge request pleroma/pleroma!1596
tags/v1.1.4
kaniini 4 years ago
parent
commit
503139b343
2 changed files with 12 additions and 2 deletions
  1. +4
    -2
      lib/pleroma/user/info.ex
  2. +8
    -0
      test/web/activity_pub/transmogrifier_test.exs

+ 4
- 2
lib/pleroma/user/info.ex View File

@@ -49,7 +49,7 @@ defmodule Pleroma.User.Info do
field(:mascot, :map, default: nil)
field(:emoji, {:array, :map}, default: [])
field(:pleroma_settings_store, :map, default: %{})
field(:fields, {:array, :map}, default: [])
field(:fields, {:array, :map}, default: nil)
field(:raw_fields, {:array, :map}, default: [])

field(:notification_settings, :map,
@@ -422,7 +422,7 @@ defmodule Pleroma.User.Info do

# ``fields`` is an array of mastodon profile field, containing ``{"name": "…", "value": "…"}``.
# For example: [{"name": "Pronoun", "value": "she/her"}, …]
def fields(%{fields: [], source_data: %{"attachment" => attachment}}) do
def fields(%{fields: nil, source_data: %{"attachment" => attachment}}) do
limit = Pleroma.Config.get([:instance, :max_remote_account_fields], 0)

attachment
@@ -431,6 +431,8 @@ defmodule Pleroma.User.Info do
|> Enum.take(limit)
end

def fields(%{fields: nil}), do: []

def fields(%{fields: fields}), do: fields

def follow_information_update(info, params) do


+ 8
- 0
test/web/activity_pub/transmogrifier_test.exs View File

@@ -563,6 +563,14 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
%{"name" => "foo", "value" => "updated"},
%{"name" => "foo1", "value" => "updated"}
]

update_data = put_in(update_data, ["object", "attachment"], [])

{:ok, _} = Transmogrifier.handle_incoming(update_data)

user = User.get_cached_by_ap_id(user.ap_id)

assert User.Info.fields(user.info) == []
end

test "it works for incoming update activities which lock the account" do


Loading…
Cancel
Save