From 0b7bd9f26fecd04e31888253b15eb505f4454265 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Fri, 11 Oct 2024 16:08:41 +0530 Subject: [PATCH] Fix yanr NoneType error --- pyrogram/methods/auth/get_active_sessions.py | 2 +- pyrogram/types/authorization/active_session.py | 10 ++++++++-- pyrogram/types/authorization/active_sessions.py | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pyrogram/methods/auth/get_active_sessions.py b/pyrogram/methods/auth/get_active_sessions.py index d8c906b86..16428247e 100644 --- a/pyrogram/methods/auth/get_active_sessions.py +++ b/pyrogram/methods/auth/get_active_sessions.py @@ -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) diff --git a/pyrogram/types/authorization/active_session.py b/pyrogram/types/authorization/active_session.py index 2322f78aa..7de247e72 100644 --- a/pyrogram/types/authorization/active_session.py +++ b/pyrogram/types/authorization/active_session.py @@ -18,6 +18,7 @@ from datetime import datetime +import pyrogram from pyrogram import raw, utils from ..object import Object @@ -86,6 +87,7 @@ class ActiveSession(Object): def __init__( self, *, + client: "pyrogram.Client" = None, id: int = None, device_model: str = None, platform: str = None, @@ -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 @@ -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, diff --git a/pyrogram/types/authorization/active_sessions.py b/pyrogram/types/authorization/active_sessions.py index 414e3e70b..593571331 100644 --- a/pyrogram/types/authorization/active_sessions.py +++ b/pyrogram/types/authorization/active_sessions.py @@ -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 ]) )