commit: 649e51b581327eb34d31e0160ea70d1cba281f9a
parent 08a444f6c3591fec60d11638587c60c5dc417a48
Author: Mark Felder <feld@feld.me>
Date: Thu, 22 Aug 2024 11:29:44 -0400
Fix Oban jobs for imports
Diffstat:
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/changelog.d/user-imports.fix b/changelog.d/user-imports.fix
@@ -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.
diff --git a/lib/pleroma/user/import.ex b/lib/pleroma/user/import.ex
@@ -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
diff --git a/test/pleroma/user/import_test.exs b/test/pleroma/user/import_test.exs
@@ -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