aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/user.ex12
-rw-r--r--mix.exs2
-rw-r--r--mix.lock2
-rw-r--r--test/pleroma/activity/search_test.exs3
-rw-r--r--test/pleroma/formatter_test.exs6
-rw-r--r--test/pleroma/user_test.exs7
-rw-r--r--test/pleroma/web/activity_pub/side_effects_test.exs2
-rw-r--r--test/pleroma/web/mastodon_api/controllers/search_controller_test.exs3
8 files changed, 26 insertions, 11 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index bcd5256c8..4b3a9d690 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -473,6 +473,18 @@ defmodule Pleroma.User do
|> validate_length(:bio, max: bio_limit)
|> validate_length(:name, max: name_limit)
|> validate_fields(true)
+ |> validate_non_local()
+ end
+
+ defp validate_non_local(cng) do
+ local? = get_field(cng, :local)
+
+ if local? do
+ cng
+ |> add_error(:local, "User is local, can't update with this changeset.")
+ else
+ cng
+ end
end
def update_changeset(struct, params \\ %{}) do
diff --git a/mix.exs b/mix.exs
index 7f6dae813..72a6346b5 100644
--- a/mix.exs
+++ b/mix.exs
@@ -158,7 +158,7 @@ defmodule Pleroma.Mixfile do
{:floki, "~> 0.27"},
{:timex, "~> 3.6"},
{:ueberauth, "~> 0.4"},
- {:linkify, "~> 0.3.0"},
+ {:linkify, "~> 0.4.0"},
{:http_signatures, "~> 0.1.0"},
{:telemetry, "~> 0.3"},
{:poolboy, "~> 1.5"},
diff --git a/mix.lock b/mix.lock
index 94df2a9b1..6b551a012 100644
--- a/mix.lock
+++ b/mix.lock
@@ -65,7 +65,7 @@
"jose": {:hex, :jose, "1.10.1", "16d8e460dae7203c6d1efa3f277e25b5af8b659febfc2f2eb4bacf87f128b80a", [:mix, :rebar3], [], "hexpm", "3c7ddc8a9394b92891db7c2771da94bf819834a1a4c92e30857b7d582e2f8257"},
"jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
"libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"},
- "linkify": {:hex, :linkify, "0.3.0", "0786296f06c3cc5455c3cbc786e575e5c381f76f8c7cb79eba495eef66617aeb", [:mix], [], "hexpm", "47e6a6e2c98815b238017331c3fbcf04aaa0644e323e6c260ee0111ed43f696c"},
+ "linkify": {:hex, :linkify, "0.4.0", "7845b6ac33050a41acaf9318923ce6e7f3854418be9a5f22184de103f7a68ff9", [:mix], [], "hexpm", "a0ceb4c78591fecccf1d99fecc10c13dba75a307c663c80e28af9e2cdd9776ee"},
"majic": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/majic.git", "4c692e544b28d1f5e543fb8a44be090f8cd96f80", [branch: "develop"]},
"makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
diff --git a/test/pleroma/activity/search_test.exs b/test/pleroma/activity/search_test.exs
index 988949154..fc910e725 100644
--- a/test/pleroma/activity/search_test.exs
+++ b/test/pleroma/activity/search_test.exs
@@ -21,6 +21,7 @@ defmodule Pleroma.Activity.SearchTest do
test "using plainto_tsquery on postgres < 11" do
old_version = :persistent_term.get({Pleroma.Repo, :postgres_version})
:persistent_term.put({Pleroma.Repo, :postgres_version}, 10.0)
+ on_exit(fn -> :persistent_term.put({Pleroma.Repo, :postgres_version}, old_version) end)
user = insert(:user)
{:ok, post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"})
@@ -30,8 +31,6 @@ defmodule Pleroma.Activity.SearchTest do
assert [result] = Search.search(nil, "wednesday -dudes")
assert result.id == post.id
-
- :persistent_term.put({Pleroma.Repo, :postgres_version}, old_version)
end
test "using websearch_to_tsquery" do
diff --git a/test/pleroma/formatter_test.exs b/test/pleroma/formatter_test.exs
index f066bd50a..5781a3f01 100644
--- a/test/pleroma/formatter_test.exs
+++ b/test/pleroma/formatter_test.exs
@@ -241,16 +241,14 @@ defmodule Pleroma.FormatterTest do
"@@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me and @o and @@@jimm"
o = insert(:user, %{nickname: "o"})
- jimm = insert(:user, %{nickname: "jimm"})
- gsimg = insert(:user, %{nickname: "gsimg"})
+ _jimm = insert(:user, %{nickname: "jimm"})
+ _gsimg = insert(:user, %{nickname: "gsimg"})
archaeme = insert(:user, %{nickname: "archaeme"})
archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
expected_mentions = [
{"@archaeme", archaeme},
{"@archaeme@archae.me", archaeme_remote},
- {"@gsimg", gsimg},
- {"@jimm", jimm},
{"@o", o}
]
diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs
index c678dadb3..e01a940cb 100644
--- a/test/pleroma/user_test.exs
+++ b/test/pleroma/user_test.exs
@@ -895,6 +895,13 @@ defmodule Pleroma.UserTest do
refute cs.valid?
end)
end
+
+ test "it is invalid given a local user" do
+ user = insert(:user)
+ cs = User.remote_user_changeset(user, %{name: "tom from myspace"})
+
+ refute cs.valid?
+ end
end
describe "followers and friends" do
diff --git a/test/pleroma/web/activity_pub/side_effects_test.exs b/test/pleroma/web/activity_pub/side_effects_test.exs
index 9efbaad04..297fc0b84 100644
--- a/test/pleroma/web/activity_pub/side_effects_test.exs
+++ b/test/pleroma/web/activity_pub/side_effects_test.exs
@@ -108,7 +108,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
describe "update users" do
setup do
- user = insert(:user)
+ user = insert(:user, local: false)
{:ok, update_data, []} = Builder.update(user, %{"id" => user.ap_id, "name" => "new name!"})
{:ok, update, _meta} = ActivityPub.persist(update_data, local: true)
diff --git a/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs
index 2f0bce450..1045ab265 100644
--- a/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs
@@ -281,6 +281,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
test "search fetches remote statuses and prefers them over other results", %{conn: conn} do
old_version = :persistent_term.get({Pleroma.Repo, :postgres_version})
:persistent_term.put({Pleroma.Repo, :postgres_version}, 10.0)
+ on_exit(fn -> :persistent_term.put({Pleroma.Repo, :postgres_version}, old_version) end)
capture_log(fn ->
{:ok, %{id: activity_id}} =
@@ -298,8 +299,6 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
%{"id" => ^activity_id}
] = results["statuses"]
end)
-
- :persistent_term.put({Pleroma.Repo, :postgres_version}, old_version)
end
test "search doesn't show statuses that it shouldn't", %{conn: conn} do