Execute session disconnect in background
This commit is contained in:
parent
f459c1260b
commit
a31d6bb52c
2 changed files with 15 additions and 3 deletions
|
@ -89,7 +89,8 @@ def start(_type, _args) do
|
|||
Pleroma.Repo,
|
||||
Config.TransferTask,
|
||||
Pleroma.Emoji,
|
||||
Pleroma.Web.Plugs.RateLimiter.Supervisor
|
||||
Pleroma.Web.Plugs.RateLimiter.Supervisor,
|
||||
{Task.Supervisor, name: Pleroma.TaskSupervisor}
|
||||
] ++
|
||||
cachex_children() ++
|
||||
http_children(adapter, @mix_env) ++
|
||||
|
|
|
@ -21,7 +21,18 @@ def revoke(%App{} = app, %{"token" => token} = _attrs) do
|
|||
@doc "Revokes access token"
|
||||
@spec revoke(Token.t()) :: {:ok, Token.t()} | {:error, Ecto.Changeset.t()}
|
||||
def revoke(%Token{} = token) do
|
||||
Repo.delete(token)
|
||||
Pleroma.Web.Streamer.close_streams_by_oauth_token(token)
|
||||
with {:ok, token} <- Repo.delete(token) do
|
||||
Task.Supervisor.start_child(
|
||||
Pleroma.TaskSupervisor,
|
||||
Pleroma.Web.Streamer,
|
||||
:close_streams_by_oauth_token,
|
||||
[token],
|
||||
restart: :transient
|
||||
)
|
||||
|
||||
{:ok, token}
|
||||
else
|
||||
result -> result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue