@@ -230,18 +230,18 @@ def create_info_response_headers(user: UsersResponseWithInbounds, sub_settings:
230230 # Only include headers that have values
231231 return {k : v for k , v in headers .items () if v }
232232
233- async def fetch_config (self , user : UsersResponseWithInbounds , client_type : ConfigFormat ) -> tuple [str , str ]:
233+ async def fetch_config (self , user : UsersResponseWithInbounds , client_type : ConfigFormat ) -> tuple [str | bytes , str ]:
234234 # Get client configuration
235- config = client_config .get (client_type )
235+ config = client_config .get (client_type , {} )
236236 sub_settings = await subscription_settings ()
237237 randomize_order = sub_settings .randomize_order
238238
239239 # Generate subscription content
240240 return (
241241 await generate_subscription (
242242 user = user ,
243- config_format = config [ "config_format" ] ,
244- as_base64 = config [ "as_base64" ] ,
243+ config_format = config . get ( "config_format" , "" ) ,
244+ as_base64 = config . get ( "as_base64" , "" ) ,
245245 randomize_order = randomize_order ,
246246 ),
247247 config ["media_type" ],
@@ -386,10 +386,20 @@ def _build_raw_subscription_payload(
386386 "apps" : self ._make_apps_import_urls (sub_settings .applications , format_variables ),
387387 }
388388
389- async def user_subscription_raw (self , db : AsyncSession , token : str ):
389+ async def user_subscription_raw (
390+ self ,
391+ db : AsyncSession ,
392+ token : str ,
393+ update_user_agent : str = "" ,
394+ ip : str | None = None ,
395+ ):
390396 sub_settings : SubSettings = await subscription_settings ()
391397 db_user = await self .get_validated_sub (db , token )
392398 user = await self .validated_user (db_user )
399+
400+ if update_user_agent :
401+ await user_sub_update (db , db_user .id , update_user_agent , ip = ip )
402+
393403 links = []
394404 if sub_settings .allow_browser_config :
395405 conf , _ = await self .fetch_config (user , ConfigFormat .links )
0 commit comments