summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-05-11 12:50:25 +0200
committerlain <lain@soykaf.club>2020-05-11 12:50:25 +0200
commitf01abaff3751f0e76de0f126b41efe801768c3f8 (patch)
treeef96b382256ff02145b0a03a534d45c8d6440198
parenta6283bbae13a873af969336bd4e62011777a1a70 (diff)
User: Truncate bios when updating a remote user.1754-bio-length-stable
-rw-r--r--lib/pleroma/user.ex10
-rw-r--r--test/user_test.exs3
-rw-r--r--test/web/activity_pub/activity_pub_controller_test.exs4
-rw-r--r--test/web/mastodon_api/controllers/suggestion_controller_test.exs2
4 files changed, 16 insertions, 3 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index 2f0333da0..3e8f19e30 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -501,7 +501,15 @@ defmodule Pleroma.User do
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
|> cast(
diff --git a/test/user_test.exs b/test/user_test.exs
index e63c44360..368bdae12 100644
--- a/test/user_test.exs
+++ b/test/user_test.exs
@@ -570,7 +570,10 @@ defmodule Pleroma.UserTest do
assert fetched_user == "not found nonexistant"
end
+ clear_config([:instance, :user_bio_length])
+
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)
orig_user =
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs
index c418232da..153adc703 100644
--- a/test/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/web/activity_pub/activity_pub_controller_test.exs
@@ -310,7 +310,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
end
describe "/inbox" do
+ clear_config([:instance, :user_bio_length])
+
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!()
conn =
diff --git a/test/web/mastodon_api/controllers/suggestion_controller_test.exs b/test/web/mastodon_api/controllers/suggestion_controller_test.exs
index 8d0e70db8..f120bd0cd 100644
--- a/test/web/mastodon_api/controllers/suggestion_controller_test.exs
+++ b/test/web/mastodon_api/controllers/suggestion_controller_test.exs
@@ -5,8 +5,6 @@
defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
use Pleroma.Web.ConnCase
- alias Pleroma.Config
-
setup do: oauth_access(["read"])
test "returns empty result", %{conn: conn} do