style: format collaboration changes

This commit is contained in:
dadachann
2026-07-26 10:54:21 +08:00
parent 8a445bfb22
commit 66a1ceac25
4 changed files with 16 additions and 25 deletions
+2 -5
View File
@@ -199,8 +199,7 @@ class SpaceLaunchService:
if not public_key_value or not key_id:
raise SpaceLaunchError('Space launch control-plane trust is not configured')
clock_skew = self._bounded_float(
os.environ.get('LANGBOT_SPACE_CONTROL_PLANE_CLOCK_SKEW_SECONDS')
or launch_config.get('clock_skew_seconds'),
os.environ.get('LANGBOT_SPACE_CONTROL_PLANE_CLOCK_SKEW_SECONDS') or launch_config.get('clock_skew_seconds'),
default=30.0,
minimum=0.0,
maximum=300.0,
@@ -211,9 +210,7 @@ class SpaceLaunchService:
digest = hashlib.sha256(jti.encode('utf-8')).hexdigest()
now = int(self._wall_time())
async with self._replay_lock:
self._consumed_jtis = {
existing: expiry for existing, expiry in self._consumed_jtis.items() if expiry > now
}
self._consumed_jtis = {existing: expiry for existing, expiry in self._consumed_jtis.items() if expiry > now}
if digest in self._consumed_jtis:
raise SpaceLaunchError('Launch assertion has already been consumed')
if len(self._consumed_jtis) >= 4096:
+1 -3
View File
@@ -1499,9 +1499,7 @@ class PersistenceManager:
local_workspace_expression = (
f"(((uuid)::text = {setting(TENANT_SETTING)}) AND ((source)::text = 'local'::text))"
)
local_membership_expression = (
f'((workspace_uuid)::text = {setting(TENANT_SETTING)})'
)
local_membership_expression = f'((workspace_uuid)::text = {setting(TENANT_SETTING)})'
local_execution_expression = (
f'(((workspace_uuid)::text = {setting(TENANT_SETTING)}) AND (EXISTS ( SELECT 1\n'
' FROM workspaces local_workspace\n'
@@ -106,7 +106,9 @@ class InvitationDeliveryService:
json=payload,
)
if response.status_code >= 400:
self._log_delivery_failure(config.provider or 'resend', RuntimeError(f'Resend returned {response.status_code}'))
self._log_delivery_failure(
config.provider or 'resend', RuntimeError(f'Resend returned {response.status_code}')
)
return False
return True
@@ -140,11 +142,7 @@ class InvitationDeliveryService:
def _email_config(self) -> _EmailConfig:
data = getattr(getattr(self.ap, 'instance_config', None), 'data', {}) or {}
email = (
data.get('workspace', {})
.get('invitations', {})
.get('email', {})
)
email = data.get('workspace', {}).get('invitations', {}).get('email', {})
if not isinstance(email, dict):
email = {}
raw_provider = self._env('WORKSPACE__INVITATIONS__EMAIL__PROVIDER', email.get('provider', ''))
@@ -189,9 +187,7 @@ class InvitationDeliveryService:
smtp_starttls = self._bool(
self._env('WORKSPACE__INVITATIONS__EMAIL__SMTP__STARTTLS', smtp_config.get('starttls', True))
)
smtp_ssl = self._bool(
self._env('WORKSPACE__INVITATIONS__EMAIL__SMTP__SSL', smtp_config.get('ssl', False))
)
smtp_ssl = self._bool(self._env('WORKSPACE__INVITATIONS__EMAIL__SMTP__SSL', smtp_config.get('ssl', False)))
if provider == 'resend' and not (sender and resend_api_key and resend_api_url):
provider = None
@@ -244,14 +240,9 @@ class InvitationDeliveryService:
@staticmethod
def _html(workspace_name: str, invitation_link: str) -> str:
escaped_workspace = (
workspace_name.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
)
escaped_workspace = workspace_name.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
escaped_link = (
invitation_link.replace('&', '&amp;')
.replace('<', '&lt;')
.replace('>', '&gt;')
.replace('"', '&quot;')
invitation_link.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;')
)
return (
'<p>You were invited to join '