d41be4e87be28b19c1306b1bc349da51340368dd
[akkoma] / lib / pleroma / workers / cron / clear_oauth_token_worker.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Workers.Cron.ClearOauthTokenWorker do
6 @moduledoc """
7 The worker to cleanup expired oAuth tokens.
8 """
9
10 use Oban.Worker, queue: "background"
11
12 alias Pleroma.Config
13 alias Pleroma.Web.OAuth.Token
14
15 @impl Oban.Worker
16 def perform(_job) do
17 if Config.get([:oauth2, :clean_expired_tokens], false) do
18 Token.delete_expired_tokens()
19 else
20 :ok
21 end
22 end
23 end