Open machine-scoped chats from Search
With several machines connected a chat id is chat@<base64url>; routes rejected the @, so a search hit fell back to /chat and closed the chat. Accept a valid machine-scoped id in chat routes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import '../core/servers/chat/chat_identity.dart';
|
||||
|
||||
part 'app_route_codec.dart';
|
||||
|
||||
/// The destinations the app has a URL for.
|
||||
@@ -140,11 +142,25 @@ class AppRoute {
|
||||
|
||||
/// A chat session id is nonempty, bounded and URL-safe, matching the web
|
||||
/// parser. Anything else is malformed rather than a stale session the
|
||||
/// destination has to guess about.
|
||||
static bool isChatSessionId(String value) =>
|
||||
value.isNotEmpty &&
|
||||
value.length <= 200 &&
|
||||
RegExp(r'^[A-Za-z0-9_-]+$').hasMatch(value);
|
||||
/// destination has to guess about. With several machines connected, a
|
||||
/// chat's id is its machine-scoped `chat@<base64url>` form
|
||||
/// ([federatedChatId]); it is valid when it decodes to a machine and a
|
||||
/// valid native id.
|
||||
static bool isChatSessionId(String value) {
|
||||
if (value.startsWith('chat@')) {
|
||||
if (value.length > 1024 || !_urlSafe.hasMatch(value.substring(5))) {
|
||||
return false;
|
||||
}
|
||||
final federated = parseFederatedChatId(value);
|
||||
return federated != null && _isNativeChatId(federated.native);
|
||||
}
|
||||
return _isNativeChatId(value);
|
||||
}
|
||||
|
||||
static final _urlSafe = RegExp(r'^[A-Za-z0-9_-]+$');
|
||||
|
||||
static bool _isNativeChatId(String value) =>
|
||||
value.isNotEmpty && value.length <= 200 && _urlSafe.hasMatch(value);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
|
||||
Reference in New Issue
Block a user