mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-05 17:32:10 +02:00
Polish off all our gross edges around frontend/backend Public name management
This commit is contained in:
@@ -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));
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user