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
21 def start_link, do: GenServer.start_link(__MODULE__, nil)
24 if Pleroma.Config.get([:oauth2, :clean_expired_tokens], false) do
25 Process.send_after(self(), :perform, @start_interval)
33 def handle_info(:perform, state) do
34 Process.send_after(self(), :perform, @interval)
35 PleromaJobQueue.enqueue(@queue, __MODULE__, [:clean])
39 # Job Worker Callbacks
40 def perform(:clean), do: Token.delete_expired_tokens()