Merge remote-tracking branch 'remotes/origin/develop' into auth-improvements
authorIvan Tashkinov <ivantashkinov@gmail.com>
Sun, 6 Dec 2020 10:59:35 +0000 (13:59 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Sun, 6 Dec 2020 10:59:35 +0000 (13:59 +0300)
1  2 
CHANGELOG.md
lib/pleroma/user.ex
test/pleroma/user_test.exs

diff --combined CHANGELOG.md
index 4b3ae2193281b836fd0b86e476615d40ee40e836,606f6e1db7c98777c3679543a1a3cbff31262406..3974885848fbc8ccba3887f5673ae3b99ca1cf7d
@@@ -11,6 -11,7 +11,7 @@@ The format is based on [Keep a Changelo
  - Polls now always return a `voters_count`, even if they are single-choice.
  - Admin Emails: The ap id is used as the user link in emails now.
  - Search: When using Postgres 11+, Pleroma will use the `websearch_to_tsvector` function to parse search queries.
+ - Emoji: Support the full Unicode 13.1 set of Emoji for reactions, plus regional indicators.
  
  ### Added
  
@@@ -23,7 -24,6 +24,7 @@@
  - Ability to view remote timelines, with ex. `/api/v1/timelines/public?instance=lain.com` and streams `public:remote` and `public:remote:media`.
  - The site title is now injected as a `title` tag like preloads or metadata.
  - Password reset tokens now are not accepted after a certain age.
 +- OAuth form improvements: users are remembered by their cookie, the CSS is overridable by the admin, and the style has been improved.
  
  <details>
    <summary>API Changes</summary>
diff --combined lib/pleroma/user.ex
index 6a5a43a2581a85164de214240492554ea20e77b2,4b3a9d690cd4566c8e1726f70b3a7225fc57b586..7d5e83a7f51bb5ade5599bb7f3cd5a3d0e43c57d
@@@ -473,6 -473,18 +473,18 @@@ defmodule Pleroma.User d
      |> 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
      |> Map.put(:bio, HTML.filter_tags(user.bio, filter))
      |> Map.put(:fields, fields)
    end
 +
 +  def get_host(%User{ap_id: ap_id} = _user) do
 +    URI.parse(ap_id).host
 +  end
  end
index 1ba7f2a2f2a14fadf02d5c2208ad5935bbd3f515,e01a940cb0b3d9ec4d195468e036f9b0df8da073..10821c31d4c874a98d0d13d3b51e90e4911fba64
@@@ -895,6 -895,13 +895,13 @@@ defmodule Pleroma.UserTest d
          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
  
      assert User.avatar_url(user, no_default: true) == nil
    end
 +
 +  test "get_host/1" do
 +    user = insert(:user, ap_id: "https://lain.com/users/lain", nickname: "lain")
 +    assert User.get_host(user) == "lain.com"
 +  end
  end