@@ -253,6 +253,7 @@ async def user_subscription(
253253 token : str ,
254254 accept_header : str = "" ,
255255 user_agent : str = "" ,
256+ ip : str | None = None ,
256257 request_url : str = "" ,
257258 ):
258259 """
@@ -301,7 +302,7 @@ async def user_subscription(
301302 await self .raise_error (message = "Client not supported" , code = 406 )
302303
303304 # Update user subscription info
304- await user_sub_update (db , db_user .id , user_agent )
305+ await user_sub_update (db , db_user .id , user_agent , ip = ip )
305306 conf , media_type = await self .fetch_config (user , client_type )
306307
307308 # If disable_sub_template is True and it's a browser request, use inline to view instead of download
@@ -397,7 +398,9 @@ async def user_subscription_by_id(
397398 db_user = await self .get_validated_user_by_id (db , user_id , admin )
398399 return await self .user_subscription_by_user (db_user , client_type , request_url )
399400
400- async def user_subscription_info (self , db : AsyncSession , token : str ) -> tuple [SubscriptionUserResponse , dict ]:
401+ async def user_subscription_info (
402+ self , db : AsyncSession , token : str , ip : str | None = None
403+ ) -> tuple [SubscriptionUserResponse , dict ]:
401404 """Retrieves detailed information about the user's subscription."""
402405 sub_settings : SubSettings = await subscription_settings ()
403406 db_user = await self .get_validated_sub (db , token = token )
@@ -409,6 +412,7 @@ async def user_subscription_info(self, db: AsyncSession, token: str) -> tuple[Su
409412 except ValueError as exc :
410413 await self .raise_error (message = str (exc ), code = 400 )
411414 user_response = SubscriptionUserResponse .model_validate (db_user )
415+ user_response .ip = ip
412416
413417 return user_response , response_headers
414418
0 commit comments