(data: {
signupDomain: string;
matchedDomain: string;
method: string;
orgId: string;
orgName: string;
companyType?: string;
source: string;
contactName?: string;
contactEmail?: string;
})
| 31 | } |
| 32 | |
| 33 | export async function notifyAliasMatch(data: { |
| 34 | signupDomain: string; |
| 35 | matchedDomain: string; |
| 36 | method: string; |
| 37 | orgId: string; |
| 38 | orgName: string; |
| 39 | companyType?: string; |
| 40 | source: string; |
| 41 | contactName?: string; |
| 42 | contactEmail?: string; |
| 43 | }): Promise<boolean> { |
| 44 | if (!isSlackConfigured()) { |
| 45 | logger.debug('Slack not configured, skipping alias match notification'); |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | const channel = await getProspectChannel(); |
| 50 | if (!channel.channel_id) { |
| 51 | logger.debug('Prospect channel not configured, skipping alias match notification'); |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | const sourceLabel = data.source === 'slack' ? 'Slack join' : data.source === 'inbound' ? 'Website signup' : data.source; |
| 56 | const methodLabel = MATCH_METHOD_LABELS[data.method] ?? data.method; |
| 57 | const text = `Signup matched to existing org: ${data.orgName} (${data.signupDomain} → ${data.matchedDomain})`; |
| 58 | |
| 59 | const fields: SlackTextObject[] = [ |
| 60 | { type: 'mrkdwn', text: `*Company:*\n${data.orgName}` }, |
| 61 | { type: 'mrkdwn', text: `*Signup domain:*\n${data.signupDomain}` }, |
| 62 | { type: 'mrkdwn', text: `*Matched domain:*\n${data.matchedDomain}` }, |
| 63 | { type: 'mrkdwn', text: `*Match method:*\n${methodLabel}` }, |
| 64 | { type: 'mrkdwn', text: `*Source:*\n${sourceLabel}` }, |
| 65 | ]; |
| 66 | |
| 67 | if (data.companyType) { |
| 68 | fields.push({ type: 'mrkdwn', text: `*Type:*\n${getCompanyTypeLabel(data.companyType)}` }); |
| 69 | } |
| 70 | |
| 71 | const blocks: SlackBlock[] = [ |
| 72 | { |
| 73 | type: 'header', |
| 74 | text: { type: 'plain_text', text: 'Signup matched to existing org', emoji: true } as SlackTextObject, |
| 75 | }, |
| 76 | { |
| 77 | type: 'section', |
| 78 | fields, |
| 79 | }, |
| 80 | ]; |
| 81 | |
| 82 | const aliasContactBlock = signedUpByBlock(data.contactName, data.contactEmail); |
| 83 | if (aliasContactBlock) blocks.push(aliasContactBlock); |
| 84 | |
| 85 | blocks.push({ |
| 86 | type: 'actions', |
| 87 | elements: [ |
| 88 | { |
| 89 | type: 'button', |
| 90 | text: { type: 'plain_text', text: 'Add domain to org', emoji: true }, |
no test coverage detected