Refactor the async user refreshing to use Oban
Previous implementation could cause duplicate simultaneous profile fetches which is not polite.
This commit is contained in:
parent
825541b27c
commit
9c67637255
5 changed files with 24 additions and 10 deletions
14
lib/pleroma/workers/user_refresh_worker.ex
Normal file
14
lib/pleroma/workers/user_refresh_worker.ex
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Workers.UserRefreshWorker do
|
||||
use Pleroma.Workers.WorkerHelper, queue: "background", max_attempts: 1, unique: [period: 300]
|
||||
|
||||
alias Pleroma.User
|
||||
|
||||
@impl Oban.Worker
|
||||
def perform(%Job{args: %{"ap_id" => ap_id}}) do
|
||||
User.fetch_by_ap_id(ap_id)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue