@@ -94,6 +94,21 @@ def create_response_headers(user: UsersResponseWithInbounds, request_url: str, s
9494 "announce-url" : sub_settings .announce_url ,
9595 }
9696
97+ @staticmethod
98+ def create_info_response_headers (user : UsersResponseWithInbounds , sub_settings : SubSettings ) -> dict :
99+ """Create response headers for /info endpoint with only support-url, announce, and announce-url."""
100+ # Prefer admin's support_url over subscription settings
101+ support_url = (getattr (user .admin , "support_url" , None ) if user .admin else None ) or sub_settings .support_url
102+
103+ headers = {
104+ "support-url" : support_url ,
105+ "announce" : encode_title (sub_settings .announce ),
106+ "announce-url" : sub_settings .announce_url ,
107+ }
108+
109+ # Only include headers that have values
110+ return {k : v for k , v in headers .items () if v }
111+
97112 async def fetch_config (self , user : UsersResponseWithInbounds , client_type : ConfigFormat ) -> tuple [str , str ]:
98113 # Get client configuration
99114 config = client_config .get (client_type )
@@ -171,15 +186,24 @@ async def user_subscription_with_client_type(
171186 # Create response headers
172187 return Response (content = conf , media_type = media_type , headers = response_headers )
173188
174- async def user_subscription_info (self , db : AsyncSession , token : str ) -> SubscriptionUserResponse :
189+ async def user_subscription_info (
190+ self , db : AsyncSession , token : str , request_url : str = ""
191+ ) -> tuple [SubscriptionUserResponse , dict ]:
175192 """Retrieves detailed information about the user's subscription."""
176- return await self .get_validated_sub (db , token = token )
193+ sub_settings : SubSettings = await subscription_settings ()
194+ db_user = await self .get_validated_sub (db , token = token )
195+ user = await self .validated_user (db_user )
196+
197+ response_headers = self .create_info_response_headers (user , sub_settings )
198+ user_response = SubscriptionUserResponse .model_validate (db_user .__dict__ )
199+
200+ return user_response , response_headers
177201
178202 async def user_subscription_apps (self , db : AsyncSession , token : str , request_url : str ) -> list [Application ]:
179203 """
180204 Get available applications for user's subscription.
181205 """
182- await self .user_subscription_info (db , token )
206+ _ , _ = await self .user_subscription_info (db , token , request_url )
183207 sub_settings : SubSettings = await subscription_settings ()
184208 return self ._make_apps_import_urls (request_url , sub_settings .applications )
185209
0 commit comments