assert [^pending_follower] = User.get_follow_requests(locked)
end
+ test "doesn't return follow requests for deactivated accounts" do
+ locked = insert(:user, locked: true)
+ pending_follower = insert(:user, %{deactivated: true})
+
+ CommonAPI.follow(pending_follower, locked)
+
+ assert true == pending_follower.deactivated
+ assert [] = User.get_follow_requests(locked)
+ end
+
test "clears follow requests when requester is blocked" do
followed = insert(:user, locked: true)
follower = insert(:user)
}
setup do: clear_config([:instance, :account_activation_required], true)
+ test "it sets the 'accepts_chat_messages' set to true" do
+ changeset = User.register_changeset(%User{}, @full_user_data)
+ assert changeset.valid?
+
+ {:ok, user} = Repo.insert(changeset)
+
+ assert user.accepts_chat_messages
+ end
+
test "it creates unconfirmed user" do
changeset = User.register_changeset(%User{}, @full_user_data)
assert changeset.valid?
refute user.last_refreshed_at == orig_user.last_refreshed_at
end
+
+ test "if nicknames clash, the old user gets a prefix with the old id to the nickname" do
+ a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)
+
+ orig_user =
+ insert(
+ :user,
+ local: false,
+ nickname: "admin@mastodon.example.org",
+ ap_id: "http://mastodon.example.org/users/harinezumigari",
+ last_refreshed_at: a_week_ago
+ )
+
+ assert orig_user.last_refreshed_at == a_week_ago
+
+ {:ok, user} = User.get_or_fetch_by_ap_id("http://mastodon.example.org/users/admin")
+
+ assert user.inbox
+
+ refute user.id == orig_user.id
+
+ orig_user = User.get_by_id(orig_user.id)
+
+ assert orig_user.nickname == "#{orig_user.id}.admin@mastodon.example.org"
+ end
+
+ @tag capture_log: true
+ test "it returns the old user if stale, but unfetchable" do
+ a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)
+
+ orig_user =
+ insert(
+ :user,
+ local: false,
+ nickname: "admin@mastodon.example.org",
+ ap_id: "http://mastodon.example.org/users/raymoo",
+ last_refreshed_at: a_week_ago
+ )
+
+ assert orig_user.last_refreshed_at == a_week_ago
+
+ {:ok, user} = User.get_or_fetch_by_ap_id("http://mastodon.example.org/users/raymoo")
+
+ assert user.last_refreshed_at == orig_user.last_refreshed_at
+ end
end
test "returns an ap_id for a user" do
assert [%{activity | thread_muted?: CommonAPI.thread_muted?(user2, activity)}] ==
ActivityPub.fetch_activities([user2.ap_id | User.following(user2)], %{
- "user" => user2
+ user: user2
})
{:ok, _user} = User.deactivate(user)
assert [] ==
ActivityPub.fetch_activities([user2.ap_id | User.following(user2)], %{
- "user" => user2
+ user: user2
})
end
end
follower = insert(:user)
{:ok, follower} = User.follow(follower, user)
+ locked_user = insert(:user, name: "locked", locked: true)
+ {:ok, _} = User.follow(user, locked_user, :follow_pending)
+
object = insert(:note, user: user)
activity = insert(:note_activity, user: user, note: object)
refute User.following?(follower, user)
assert %{deactivated: true} = User.get_by_id(user.id)
+ assert [] == User.get_follow_requests(locked_user)
+
user_activities =
user.ap_id
|> Activity.Queries.by_actor()
end
end
- describe "visible_for?/2" do
+ describe "visible_for/2" do
test "returns true when the account is itself" do
user = insert(:user, local: true)
- assert User.visible_for?(user, user)
+ assert User.visible_for(user, user) == :visible
end
test "returns false when the account is unauthenticated and auth is required" do
user = insert(:user, local: true, confirmation_pending: true)
other_user = insert(:user, local: true)
- refute User.visible_for?(user, other_user)
+ refute User.visible_for(user, other_user) == :visible
end
test "returns true when the account is unauthenticated and auth is not required" do
user = insert(:user, local: true, confirmation_pending: true)
other_user = insert(:user, local: true)
- assert User.visible_for?(user, other_user)
+ assert User.visible_for(user, other_user) == :visible
end
test "returns true when the account is unauthenticated and being viewed by a privileged account (auth required)" do
user = insert(:user, local: true, confirmation_pending: true)
other_user = insert(:user, local: true, is_admin: true)
- assert User.visible_for?(user, other_user)
+ assert User.visible_for(user, other_user) == :visible
end
end
user = insert(:user)
assert User.avatar_url(user) =~ "/images/avi.png"
- Pleroma.Config.put([:assets, :default_user_avatar], "avatar.png")
+ clear_config([:assets, :default_user_avatar], "avatar.png")
user = User.get_cached_by_nickname_or_id(user.nickname)
assert User.avatar_url(user) =~ "avatar.png"