From: Ivan Tashkinov Date: Sun, 6 Dec 2020 10:59:35 +0000 (+0300) Subject: Merge remote-tracking branch 'remotes/origin/develop' into auth-improvements X-Git-Url: http://git.squeep.com/?a=commitdiff_plain;h=a010c5b16a395d823a98cd088c83acd098930ade;hp=-c;p=akkoma Merge remote-tracking branch 'remotes/origin/develop' into auth-improvements --- a010c5b16a395d823a98cd088c83acd098930ade diff --combined CHANGELOG.md index 4b3ae2193,606f6e1db..397488584 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@@ -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.
API Changes diff --combined lib/pleroma/user.ex index 6a5a43a25,4b3a9d690..7d5e83a7f --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@@ -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 @@@ -2406,8 -2418,4 +2418,8 @@@ |> 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 diff --combined test/pleroma/user_test.exs index 1ba7f2a2f,e01a940cb..10821c31d --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@@ -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 @@@ -2171,9 -2178,4 +2178,9 @@@ 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