Polish off all our gross edges around frontend/backend Public name management

This commit is contained in:
Jack Kingsman
2026-03-15 18:20:43 -07:00
parent c76f230c9f
commit c809dad05d
46 changed files with 311 additions and 140 deletions
+12
View File
@@ -0,0 +1,12 @@
import type { Channel } from '../types';
export const PUBLIC_CHANNEL_KEY = '8B3387E9C5CDEA6AC9E5EDBAA115CD72';
export const PUBLIC_CHANNEL_NAME = 'Public';
export function isPublicChannelKey(key: string): boolean {
return key.toUpperCase() === PUBLIC_CHANNEL_KEY;
}
export function findPublicChannel(channels: Channel[]): Channel | undefined {
return channels.find((channel) => isPublicChannelKey(channel.key));
}
+8
View File
@@ -1,4 +1,5 @@
import type { Channel, Contact, Conversation } from '../types';
import { findPublicChannel, PUBLIC_CHANNEL_NAME } from './publicChannel';
import { getContactDisplayName } from './pubkey';
interface ParsedHashConversation {
@@ -77,6 +78,13 @@ export function resolveChannelFromHashToken(token: string, channels: Channel[]):
const byKey = channels.find((c) => c.key.toLowerCase() === normalizedToken.toLowerCase());
if (byKey) return byKey;
// Legacy Public hashes should resolve to the canonical Public key, not any
// arbitrary row that happens to share the display name.
if (normalizedToken.toLowerCase() === PUBLIC_CHANNEL_NAME.toLowerCase()) {
const publicChannel = findPublicChannel(channels);
if (publicChannel) return publicChannel;
}
// Backward compatibility for legacy name-based hashes.
return (
channels.find((c) => c.name === normalizedToken || c.name === `#${normalizedToken}`) || null