X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fchannels%2Fuser_socket.ex;h=1c09b67682fbaa49073d1ad035065e42d2e0f251;hb=0ada3fe823a3c2e6c5835431bdacfbdb8b3d02a7;hp=23ba5a381615c9d9bc58551c2c8fd35e9c17f001;hpb=2791ce9a1ff2365ac7256f5e1dc2324dee2f82c9;p=akkoma
diff --git a/lib/pleroma/web/channels/user_socket.ex b/lib/pleroma/web/channels/user_socket.ex
index 23ba5a381..1c09b6768 100644
--- a/lib/pleroma/web/channels/user_socket.ex
+++ b/lib/pleroma/web/channels/user_socket.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.UserSocket do
@@ -23,8 +23,8 @@ defmodule Pleroma.Web.UserSocket do
# performing token verification on connect.
def connect(%{"token" => token}, socket) do
with true <- Pleroma.Config.get([:chat, :enabled]),
- {:ok, user_id} <- Phoenix.Token.verify(socket, "user socket", token, max_age: 84600),
- %User{} = user <- Pleroma.Repo.get(User, user_id) do
+ {:ok, user_id} <- Phoenix.Token.verify(socket, "user socket", token, max_age: 84_600),
+ %User{} = user <- Pleroma.User.get_cached_by_id(user_id) do
{:ok, assign(socket, :user_name, user.nickname)}
else
_e -> :error