Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

942 B
Raw Blame
import { getDisplayName } from './displayName';
import { tryMacroId } from './macroId';
import type { IUser } from './types';

// TODO: consolidate idToEmail, see idToEmail in email.ts
/**
 * Converts a user id to an email address.
 * @deprecated Use `macroIdToEmail` with a validated `MacroId` instead.
 */
export function idToEmail(id: string): string {
  return id.replace('macro|', '');
}

/**
 * Converts an email address to a user id.
 * @deprecated Use `emailToMacroId` instead for type-safe MacroId creation.
 */
export function emailToId(email: string): string {
  return `macro|${email}`;
}

export function idToDisplayName(id: string): string {
  return getDisplayName(tryMacroId(id), {
    emailFallback: 'local-part',
  });
}

export function channelParticipantInfo(participant: {
  user_id: string;
}): IUser {
  const id = participant.user_id;
  return {
    id,
    email: idToEmail(id),
    name: idToDisplayName(id),
  };
}