Skip to content

Commit b045399

Browse files
committed
chore: unnecessary else
1 parent a30846f commit b045399

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

app/db/crud/user.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,7 @@ async def remove_users(db: AsyncSession, db_users: list[User]):
504504
user_ids = [user.id for user in db_users]
505505

506506
# Delete related subscription updates first
507-
await db.execute(
508-
delete(UserSubscriptionUpdate).where(UserSubscriptionUpdate.user_id.in_(user_ids))
509-
)
507+
await db.execute(delete(UserSubscriptionUpdate).where(UserSubscriptionUpdate.user_id.in_(user_ids)))
510508

511509
await asyncio.gather(*[db.delete(user) for user in db_users])
512510
await db.commit()

app/operation/subscription.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@ async def detect_client_type(user_agent: str, rules: list[SubRule]) -> ConfigFor
4949
def create_response_headers(user: UsersResponseWithInbounds, request_url: str, sub_settings: SubSettings) -> dict:
5050
"""Create response headers for subscription responses, including user subscription info."""
5151
# Generate user subscription info
52-
user_info = {"upload": 0, "download": user.used_traffic}
52+
user_info = {"upload": 0, "download": user.used_traffic, "expire": 0}
5353

5454
if user.data_limit:
5555
user_info["total"] = user.data_limit
56-
56+
5757
# Always include expire key - use 0 if no expiration date
5858
if user.expire:
5959
user_info["expire"] = int(user.expire.timestamp())
60-
else:
61-
user_info["expire"] = 0
6260

6361
# Create and return headers
6462
return {

app/subscription/singbox.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ def _transport_ws(self, config: WebSocketTransportConfig, path: str) -> dict:
136136

137137
def _transport_grpc(self, config: GRPCTransportConfig, path: str) -> dict:
138138
"""Handle GRPC transport - only gets GRPC config"""
139-
return self._normalize_and_remove_none_values({
140-
"type": "grpc",
141-
"service_name": path,
142-
"idle_timeout": f"{config.idle_timeout}s" if config.idle_timeout else "15s",
143-
"ping_timeout": f"{config.health_check_timeout}s" if config.health_check_timeout else "15s",
144-
"permit_without_stream": config.permit_without_stream,
145-
})
139+
return self._normalize_and_remove_none_values(
140+
{
141+
"type": "grpc",
142+
"service_name": path,
143+
"idle_timeout": f"{config.idle_timeout}s" if config.idle_timeout else "15s",
144+
"ping_timeout": f"{config.health_check_timeout}s" if config.health_check_timeout else "15s",
145+
"permit_without_stream": config.permit_without_stream,
146+
}
147+
)
146148

147149
def _transport_httpupgrade(self, config: WebSocketTransportConfig, path: str) -> dict:
148150
"""Handle HTTPUpgrade transport - only gets WS config (similar to WS)"""
@@ -190,7 +192,10 @@ def _apply_tls(self, tls_config: TLSConfig, fragment_settings: dict | None = Non
190192
if isinstance(tls_config.sni, str)
191193
else (tls_config.sni[0] if tls_config.sni else None),
192194
"insecure": tls_config.allowinsecure,
193-
"utls": {"enabled": bool(tls_config.fingerprint) or tls_config.tls == "reality", "fingerprint": tls_config.fingerprint}
195+
"utls": {
196+
"enabled": bool(tls_config.fingerprint) or tls_config.tls == "reality",
197+
"fingerprint": tls_config.fingerprint,
198+
}
194199
if tls_config.fingerprint or tls_config.tls == "reality"
195200
else None,
196201
"alpn": tls_config.alpn_singbox, # Pre-formatted for sing-box!
@@ -322,7 +327,7 @@ def _build_outbound(
322327
if inbound.mux_settings and (singbox_mux := inbound.mux_settings.get("sing_box")) and singbox_mux.get("enable"):
323328
# Filter out the enable field as it's not part of singbox multiplex config
324329
multiplex_config = {k: v for k, v in singbox_mux.items() if k != "enable"}
325-
330+
326331
# Handle brutal configuration - only include if brutal.enable is True
327332
if "brutal" in multiplex_config:
328333
brutal_config = multiplex_config["brutal"]
@@ -332,7 +337,7 @@ def _build_outbound(
332337
else:
333338
# Remove brutal config entirely if enable is False or brutal is None
334339
multiplex_config.pop("brutal", None)
335-
340+
336341
multiplex_config = self._normalize_and_remove_none_values(multiplex_config)
337342
config["multiplex"] = multiplex_config
338343

0 commit comments

Comments
 (0)