forked from YokaiRick/akkoma
Merge branch 'fix/902-random-compile-failing' into 'develop'
Fix/902 random compile failing Closes #902 See merge request pleroma/pleroma!1168
This commit is contained in:
commit
3e5301ad5c
15 changed files with 36 additions and 35 deletions
|
@ -55,7 +55,7 @@ defmodule Pleroma.User do
|
|||
field(:last_refreshed_at, :naive_datetime_usec)
|
||||
has_many(:notifications, Notification)
|
||||
has_many(:registrations, Registration)
|
||||
embeds_one(:info, Pleroma.User.Info)
|
||||
embeds_one(:info, User.Info)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
@ -233,7 +233,7 @@ def register_changeset(struct, params \\ %{}, opts \\ []) do
|
|||
|> validate_confirmation(:password)
|
||||
|> unique_constraint(:email)
|
||||
|> unique_constraint(:nickname)
|
||||
|> validate_exclusion(:nickname, Pleroma.Config.get([Pleroma.User, :restricted_nicknames]))
|
||||
|> validate_exclusion(:nickname, Pleroma.Config.get([User, :restricted_nicknames]))
|
||||
|> validate_format(:nickname, local_nickname_regex())
|
||||
|> validate_format(:email, @email_regex)
|
||||
|> validate_length(:bio, max: 1000)
|
||||
|
@ -278,7 +278,7 @@ def register(%Ecto.Changeset{} = changeset) do
|
|||
with {:ok, user} <- Repo.insert(changeset),
|
||||
{:ok, user} <- autofollow_users(user),
|
||||
{:ok, user} <- set_cache(user),
|
||||
{:ok, _} <- Pleroma.User.WelcomeMessage.post_welcome_message_to_user(user),
|
||||
{:ok, _} <- User.WelcomeMessage.post_welcome_message_to_user(user),
|
||||
{:ok, _} <- try_send_confirmation_email(user) do
|
||||
{:ok, user}
|
||||
end
|
||||
|
|
|
@ -11,7 +11,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
alias Pleroma.Object.Containment
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.Utils
|
||||
alias Pleroma.Web.ActivityPub.Visibility
|
||||
|
|
|
@ -200,7 +200,7 @@ def update(user) do
|
|||
user =
|
||||
with emoji <- emoji_from_profile(user),
|
||||
source_data <- (user.info.source_data || %{}) |> Map.put("tag", emoji),
|
||||
info_cng <- Pleroma.User.Info.set_source_data(user.info, source_data),
|
||||
info_cng <- User.Info.set_source_data(user.info, source_data),
|
||||
change <- Ecto.Changeset.change(user) |> Ecto.Changeset.put_embed(:info, info_cng),
|
||||
{:ok, user} <- User.update_and_set_cache(change) do
|
||||
user
|
||||
|
@ -233,7 +233,7 @@ def pin(id_or_ap_id, %{ap_id: user_ap_id} = user) do
|
|||
} = activity <- get_by_id_or_ap_id(id_or_ap_id),
|
||||
true <- Enum.member?(object_to, "https://www.w3.org/ns/activitystreams#Public"),
|
||||
%{valid?: true} = info_changeset <-
|
||||
Pleroma.User.Info.add_pinnned_activity(user.info, activity),
|
||||
User.Info.add_pinnned_activity(user.info, activity),
|
||||
changeset <-
|
||||
Ecto.Changeset.change(user) |> Ecto.Changeset.put_embed(:info, info_changeset),
|
||||
{:ok, _user} <- User.update_and_set_cache(changeset) do
|
||||
|
@ -250,7 +250,7 @@ def pin(id_or_ap_id, %{ap_id: user_ap_id} = user) do
|
|||
def unpin(id_or_ap_id, user) do
|
||||
with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id),
|
||||
%{valid?: true} = info_changeset <-
|
||||
Pleroma.User.Info.remove_pinnned_activity(user.info, activity),
|
||||
User.Info.remove_pinnned_activity(user.info, activity),
|
||||
changeset <-
|
||||
Ecto.Changeset.change(user) |> Ecto.Changeset.put_embed(:info, info_changeset),
|
||||
{:ok, _user} <- User.update_and_set_cache(changeset) do
|
||||
|
|
|
@ -52,9 +52,9 @@ def perform(type, _, _) do
|
|||
@doc """
|
||||
Relays an activity to all specified peers.
|
||||
"""
|
||||
@callback publish(Pleroma.User.t(), Pleroma.Activity.t()) :: :ok | {:error, any()}
|
||||
@callback publish(User.t(), Activity.t()) :: :ok | {:error, any()}
|
||||
|
||||
@spec publish(Pleroma.User.t(), Pleroma.Activity.t()) :: :ok
|
||||
@spec publish(User.t(), Activity.t()) :: :ok
|
||||
def publish(%User{} = user, %Activity{} = activity) do
|
||||
Config.get([:instance, :federation_publisher_modules])
|
||||
|> Enum.each(fn module ->
|
||||
|
@ -70,9 +70,9 @@ def publish(%User{} = user, %Activity{} = activity) do
|
|||
@doc """
|
||||
Gathers links used by an outgoing federation module for WebFinger output.
|
||||
"""
|
||||
@callback gather_webfinger_links(Pleroma.User.t()) :: list()
|
||||
@callback gather_webfinger_links(User.t()) :: list()
|
||||
|
||||
@spec gather_webfinger_links(Pleroma.User.t()) :: list()
|
||||
@spec gather_webfinger_links(User.t()) :: list()
|
||||
def gather_webfinger_links(%User{} = user) do
|
||||
Config.get([:instance, :federation_publisher_modules])
|
||||
|> Enum.reduce([], fn module, links ->
|
||||
|
|
|
@ -1222,7 +1222,7 @@ def remove_from_list(%{assigns: %{user: user}} = conn, %{"id" => id, "account_id
|
|||
accounts
|
||||
|> Enum.each(fn account_id ->
|
||||
with %Pleroma.List{} = list <- Pleroma.List.get(id, user),
|
||||
%User{} = followed <- Pleroma.User.get_cached_by_id(account_id) do
|
||||
%User{} = followed <- User.get_cached_by_id(account_id) do
|
||||
Pleroma.List.unfollow(list, followed)
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule Pleroma.Web.OAuth.Authorization do
|
|||
field(:scopes, {:array, :string}, default: [])
|
||||
field(:valid_until, :naive_datetime_usec)
|
||||
field(:used, :boolean, default: false)
|
||||
belongs_to(:user, Pleroma.User, type: Pleroma.FlakeId)
|
||||
belongs_to(:user, User, type: Pleroma.FlakeId)
|
||||
belongs_to(:app, App)
|
||||
|
||||
timestamps()
|
||||
|
|
|
@ -22,7 +22,7 @@ defmodule Pleroma.Web.OAuth.Token do
|
|||
field(:refresh_token, :string)
|
||||
field(:scopes, {:array, :string}, default: [])
|
||||
field(:valid_until, :naive_datetime_usec)
|
||||
belongs_to(:user, Pleroma.User, type: Pleroma.FlakeId)
|
||||
belongs_to(:user, User, type: Pleroma.FlakeId)
|
||||
belongs_to(:app, App)
|
||||
|
||||
timestamps()
|
||||
|
|
|
@ -99,7 +99,7 @@ def ensure_keys_present(user) do
|
|||
|
||||
info_cng =
|
||||
info
|
||||
|> Pleroma.User.Info.set_keys(pem)
|
||||
|> User.Info.set_keys(pem)
|
||||
|
||||
cng =
|
||||
Ecto.Changeset.change(user)
|
||||
|
|
|
@ -125,7 +125,7 @@ test "gives a replacement for user links, using local nicknames in user links te
|
|||
archaeme =
|
||||
insert(:user, %{
|
||||
nickname: "archa_eme_",
|
||||
info: %Pleroma.User.Info{source_data: %{"url" => "https://archeme/@archa_eme_"}}
|
||||
info: %User.Info{source_data: %{"url" => "https://archeme/@archa_eme_"}}
|
||||
})
|
||||
|
||||
archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Plugs.LegacyAuthenticationPlugTest do
|
||||
use Pleroma.Web.ConnCase, async: true
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.Plugs.LegacyAuthenticationPlug
|
||||
alias Pleroma.User
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
defmodule Pleroma.RepoTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
alias Pleroma.User
|
||||
|
||||
describe "find_resource/1" do
|
||||
test "returns user" do
|
||||
user = insert(:user)
|
||||
query = from(t in Pleroma.User, where: t.id == ^user.id)
|
||||
query = from(t in User, where: t.id == ^user.id)
|
||||
assert Repo.find_resource(query) == {:ok, user}
|
||||
end
|
||||
|
||||
test "returns not_found" do
|
||||
query = from(t in Pleroma.User, where: t.id == ^"9gBuXNpD2NyDmmxxdw")
|
||||
query = from(t in User, where: t.id == ^"9gBuXNpD2NyDmmxxdw")
|
||||
assert Repo.find_resource(query) == {:error, :not_found}
|
||||
end
|
||||
end
|
||||
|
||||
describe "get_assoc/2" do
|
||||
test "get assoc from preloaded data" do
|
||||
user = %Pleroma.User{name: "Agent Smith"}
|
||||
user = %User{name: "Agent Smith"}
|
||||
token = %Pleroma.Web.OAuth.Token{insert(:oauth_token) | user: user}
|
||||
assert Repo.get_assoc(token, :user) == {:ok, user}
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Factory do
|
||||
use ExMachina.Ecto, repo: Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
|
||||
def participation_factory do
|
||||
conversation = insert(:conversation)
|
||||
|
@ -23,7 +24,7 @@ def conversation_factory do
|
|||
end
|
||||
|
||||
def user_factory do
|
||||
user = %Pleroma.User{
|
||||
user = %User{
|
||||
name: sequence(:name, &"Test テスト User #{&1}"),
|
||||
email: sequence(:email, &"user#{&1}@example.com"),
|
||||
nickname: sequence(:nickname, &"nick#{&1}"),
|
||||
|
@ -34,9 +35,9 @@ def user_factory do
|
|||
|
||||
%{
|
||||
user
|
||||
| ap_id: Pleroma.User.ap_id(user),
|
||||
follower_address: Pleroma.User.ap_followers(user),
|
||||
following: [Pleroma.User.ap_id(user)]
|
||||
| ap_id: User.ap_id(user),
|
||||
follower_address: User.ap_followers(user),
|
||||
following: [User.ap_id(user)]
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ test "it requires an email, name, nickname and password, bio is optional" do
|
|||
end
|
||||
|
||||
test "it restricts certain nicknames" do
|
||||
[restricted_name | _] = Pleroma.Config.get([Pleroma.User, :restricted_nicknames])
|
||||
[restricted_name | _] = Pleroma.Config.get([User, :restricted_nicknames])
|
||||
|
||||
assert is_bitstring(restricted_name)
|
||||
|
||||
|
@ -1223,11 +1223,11 @@ test "follower count is updated when a follower is blocked" do
|
|||
follower2 = insert(:user)
|
||||
follower3 = insert(:user)
|
||||
|
||||
{:ok, follower} = Pleroma.User.follow(follower, user)
|
||||
{:ok, _follower2} = Pleroma.User.follow(follower2, user)
|
||||
{:ok, _follower3} = Pleroma.User.follow(follower3, user)
|
||||
{:ok, follower} = User.follow(follower, user)
|
||||
{:ok, _follower2} = User.follow(follower2, user)
|
||||
{:ok, _follower3} = User.follow(follower3, user)
|
||||
|
||||
{:ok, _} = Pleroma.User.block(user, follower)
|
||||
{:ok, _} = User.block(user, follower)
|
||||
|
||||
user_show = Pleroma.Web.TwitterAPI.UserView.render("show.json", %{user: user})
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ test "verify_credentials", %{conn: conn} do
|
|||
end
|
||||
|
||||
test "verify_credentials default scope unlisted", %{conn: conn} do
|
||||
user = insert(:user, %{info: %Pleroma.User.Info{default_scope: "unlisted"}})
|
||||
user = insert(:user, %{info: %User.Info{default_scope: "unlisted"}})
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
@ -1322,7 +1322,7 @@ test "returns the relationships for the current user", %{conn: conn} do
|
|||
|
||||
describe "locked accounts" do
|
||||
test "/api/v1/follow_requests works" do
|
||||
user = insert(:user, %{info: %Pleroma.User.Info{locked: true}})
|
||||
user = insert(:user, %{info: %User.Info{locked: true}})
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
@ -1367,7 +1367,7 @@ test "/api/v1/follow_requests/:id/authorize works" do
|
|||
end
|
||||
|
||||
test "verify_credentials", %{conn: conn} do
|
||||
user = insert(:user, %{info: %Pleroma.User.Info{default_scope: "private"}})
|
||||
user = insert(:user, %{info: %User.Info{default_scope: "private"}})
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
@ -1379,7 +1379,7 @@ test "verify_credentials", %{conn: conn} do
|
|||
end
|
||||
|
||||
test "/api/v1/follow_requests/:id/reject works" do
|
||||
user = insert(:user, %{info: %Pleroma.User.Info{locked: true}})
|
||||
user = insert(:user, %{info: %User.Info{locked: true}})
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
|
|
@ -355,7 +355,7 @@ test "tries to use the information in poco fields" do
|
|||
|
||||
{:ok, user} = OStatus.find_or_make_user(uri)
|
||||
|
||||
user = Pleroma.User.get_cached_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
assert user.name == "Constance Variable"
|
||||
assert user.nickname == "lambadalambda@social.heldscal.la"
|
||||
assert user.local == false
|
||||
|
@ -374,7 +374,7 @@ test "find_or_make_user sets all the nessary input fields" do
|
|||
{:ok, user} = OStatus.find_or_make_user(uri)
|
||||
|
||||
assert user.info ==
|
||||
%Pleroma.User.Info{
|
||||
%User.Info{
|
||||
id: user.info.id,
|
||||
ap_enabled: false,
|
||||
background: %{},
|
||||
|
|
Loading…
Reference in a new issue