Skip to content

Commit 0b7bd9f

Browse files
authored
Fix yanr NoneType error
1 parent fc27f9a commit 0b7bd9f

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

pyrogram/methods/auth/get_active_sessions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ async def get_active_sessions(
3737
r = await self.invoke(
3838
raw.functions.account.GetAuthorizations()
3939
)
40-
return types.ActiveSessions._parse(r)
40+
return types.ActiveSessions._parse(self, r)

pyrogram/types/authorization/active_session.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from datetime import datetime
2020

21+
import pyrogram
2122
from pyrogram import raw, utils
2223

2324
from ..object import Object
@@ -86,6 +87,7 @@ class ActiveSession(Object):
8687
def __init__(
8788
self,
8889
*,
90+
client: "pyrogram.Client" = None,
8991
id: int = None,
9092
device_model: str = None,
9193
platform: str = None,
@@ -105,7 +107,7 @@ def __init__(
105107
can_accept_calls: bool = None,
106108
is_official_application: bool = None
107109
):
108-
super().__init__()
110+
super().__init__(client)
109111

110112
self.id = id
111113
self.device_model = device_model
@@ -127,8 +129,12 @@ def __init__(
127129
self.is_official_application = is_official_application
128130

129131
@staticmethod
130-
def _parse(session: "raw.types.Authorization") -> "ActiveSession":
132+
def _parse(
133+
client: "pyrogram.Client",
134+
session: "raw.types.Authorization"
135+
) -> "ActiveSession":
131136
return ActiveSession(
137+
client=client,
132138
id=session.hash,
133139
device_model=session.device_model,
134140
platform=session.platform,

pyrogram/types/authorization/active_sessions.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ def __init__(
4848
self.active_sessions = active_sessions
4949

5050
@staticmethod
51-
def _parse(authorizations: "raw.types.account.Authorizations") -> "ActiveSessions":
51+
def _parse(
52+
client: "pyrogram.Client",
53+
authorizations: "raw.types.account.Authorizations"
54+
) -> "ActiveSessions":
5255
return ActiveSessions(
5356
inactive_session_ttl_days=authorizations.authorization_ttl_days,
5457
active_sessions=types.List([
55-
types.ActiveSession._parse(active)
58+
types.ActiveSession._parse(client, active)
5659
for active in authorizations.authorizations
5760
])
5861
)

0 commit comments

Comments
 (0)