User: Truncate bios when updating a remote user.
This commit is contained in:
parent
3a63f84c45
commit
3f13437a9c
|
@ -501,7 +501,15 @@ def upgrade_changeset(struct, params \\ %{}, remote? \\ false) do
|
||||||
|
|
||||||
params = Map.put(params, :last_refreshed_at, NaiveDateTime.utc_now())
|
params = Map.put(params, :last_refreshed_at, NaiveDateTime.utc_now())
|
||||||
|
|
||||||
params = if remote?, do: truncate_fields_param(params), else: params
|
params =
|
||||||
|
if remote? do
|
||||||
|
params
|
||||||
|
|> truncate_fields_param()
|
||||||
|
|> truncate_if_exists(:name, name_limit)
|
||||||
|
|> truncate_if_exists(:bio, bio_limit)
|
||||||
|
else
|
||||||
|
params
|
||||||
|
end
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|> cast(
|
|> cast(
|
||||||
|
|
|
@ -570,7 +570,10 @@ test "returns nil for nonexistant local user" do
|
||||||
assert fetched_user == "not found nonexistant"
|
assert fetched_user == "not found nonexistant"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
clear_config([:instance, :user_bio_length])
|
||||||
|
|
||||||
test "updates an existing user, if stale" do
|
test "updates an existing user, if stale" do
|
||||||
|
Pleroma.Config.put([:instance, :user_bio_length], 1)
|
||||||
a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)
|
a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)
|
||||||
|
|
||||||
orig_user =
|
orig_user =
|
||||||
|
|
|
@ -310,7 +310,11 @@ test "cached purged after activity deletion", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "/inbox" do
|
describe "/inbox" do
|
||||||
|
clear_config([:instance, :user_bio_length])
|
||||||
|
|
||||||
test "it inserts an incoming activity into the database", %{conn: conn} do
|
test "it inserts an incoming activity into the database", %{conn: conn} do
|
||||||
|
Pleroma.Config.put([:instance, :user_bio_length], 1)
|
||||||
|
|
||||||
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
|
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
|
defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
alias Pleroma.Config
|
|
||||||
|
|
||||||
setup do: oauth_access(["read"])
|
setup do: oauth_access(["read"])
|
||||||
|
|
||||||
test "returns empty result", %{conn: conn} do
|
test "returns empty result", %{conn: conn} do
|
||||||
|
|
Loading…
Reference in New Issue