1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.OAuth.Token.CleanWorker do
7 The module represents functions to clean an expired oauth tokens.
11 @start_interval 10_000
12 @interval Pleroma.Config.get(
14 [:oauth2, :clean_expired_tokens_interval],
19 alias Pleroma.Web.OAuth.Token
20 alias Pleroma.Workers.BackgroundWorker
22 defdelegate worker_args(queue), to: Pleroma.Workers.Helper
24 def start_link, do: GenServer.start_link(__MODULE__, nil)
27 if Pleroma.Config.get([:oauth2, :clean_expired_tokens], false) do
28 Process.send_after(self(), :perform, @start_interval)
36 def handle_info(:perform, state) do
37 %{"op" => "clean_expired_tokens"}
38 |> BackgroundWorker.new(worker_args(:background))
41 Process.send_after(self(), :perform, @interval)
45 # Job Worker Callbacks
46 def perform(:clean), do: Token.delete_expired_tokens()