Skip to content

Commit

Permalink
Fix yanr NoneType error
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe authored Oct 11, 2024
1 parent fc27f9a commit 0b7bd9f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyrogram/methods/auth/get_active_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ async def get_active_sessions(
r = await self.invoke(
raw.functions.account.GetAuthorizations()
)
return types.ActiveSessions._parse(r)
return types.ActiveSessions._parse(self, r)
10 changes: 8 additions & 2 deletions pyrogram/types/authorization/active_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from datetime import datetime

import pyrogram
from pyrogram import raw, utils

from ..object import Object
Expand Down Expand Up @@ -86,6 +87,7 @@ class ActiveSession(Object):
def __init__(
self,
*,
client: "pyrogram.Client" = None,
id: int = None,
device_model: str = None,
platform: str = None,
Expand All @@ -105,7 +107,7 @@ def __init__(
can_accept_calls: bool = None,
is_official_application: bool = None
):
super().__init__()
super().__init__(client)

self.id = id
self.device_model = device_model
Expand All @@ -127,8 +129,12 @@ def __init__(
self.is_official_application = is_official_application

@staticmethod
def _parse(session: "raw.types.Authorization") -> "ActiveSession":
def _parse(
client: "pyrogram.Client",
session: "raw.types.Authorization"
) -> "ActiveSession":
return ActiveSession(
client=client,
id=session.hash,
device_model=session.device_model,
platform=session.platform,
Expand Down
7 changes: 5 additions & 2 deletions pyrogram/types/authorization/active_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ def __init__(
self.active_sessions = active_sessions

@staticmethod
def _parse(authorizations: "raw.types.account.Authorizations") -> "ActiveSessions":
def _parse(
client: "pyrogram.Client",
authorizations: "raw.types.account.Authorizations"
) -> "ActiveSessions":
return ActiveSessions(
inactive_session_ttl_days=authorizations.authorization_ttl_days,
active_sessions=types.List([
types.ActiveSession._parse(active)
types.ActiveSession._parse(client, active)
for active in authorizations.authorizations
])
)

0 comments on commit 0b7bd9f

Please sign in to comment.