Fix Oban jobs for imports

This commit is contained in:
Mark Felder 2024-08-22 11:29:44 -04:00
parent 08a444f6c3
commit 649e51b581
3 changed files with 7 additions and 6 deletions

View file

@ -0,0 +1 @@
Imports of blocks, mutes, and following would retry until Oban runs out of attempts due to incorrect return value being considered an error.

View file

@ -18,7 +18,7 @@ defmodule Pleroma.User.Import do
fn identifier ->
with {:ok, %User{} = muted_user} <- User.get_or_fetch(identifier),
{:ok, _} <- User.mute(user, muted_user) do
muted_user
{:ok, muted_user}
else
error -> handle_error(:mutes_import, identifier, error)
end
@ -32,7 +32,7 @@ defmodule Pleroma.User.Import do
fn identifier ->
with {:ok, %User{} = blocked} <- User.get_or_fetch(identifier),
{:ok, _block} <- CommonAPI.block(blocked, blocker) do
blocked
{:ok, blocked}
else
error -> handle_error(:blocks_import, identifier, error)
end
@ -47,7 +47,7 @@ defmodule Pleroma.User.Import do
with {:ok, %User{} = followed} <- User.get_or_fetch(identifier),
{:ok, follower, followed} <- User.maybe_direct_follow(follower, followed),
{:ok, _, _, _} <- CommonAPI.follow(followed, follower) do
followed
{:ok, followed}
else
error -> handle_error(:follow_import, identifier, error)
end

View file

@ -29,7 +29,7 @@ defmodule Pleroma.User.ImportTest do
assert {:ok, result} = ObanHelpers.perform(job)
assert is_list(result)
assert result == [refresh_record(user2), refresh_record(user3)]
assert result == [{:ok, refresh_record(user2)}, {:ok, refresh_record(user3)}]
assert User.following?(user1, user2)
assert User.following?(user1, user3)
end
@ -48,7 +48,7 @@ defmodule Pleroma.User.ImportTest do
assert {:ok, result} = ObanHelpers.perform(job)
assert is_list(result)
assert result == [user2, user3]
assert result == [{:ok, user2}, {:ok, user3}]
assert User.blocks?(user1, user2)
assert User.blocks?(user1, user3)
end
@ -67,7 +67,7 @@ defmodule Pleroma.User.ImportTest do
assert {:ok, result} = ObanHelpers.perform(job)
assert is_list(result)
assert result == [user2, user3]
assert result == [{:ok, user2}, {:ok, user3}]
assert User.mutes?(user1, user2)
assert User.mutes?(user1, user3)
end