( recipientName: string, message: string, teamContext: AppState['teamContext'], writeToMailbox?: WriteToMailboxFn, )
| 37 | * Send a direct message to a team member, bypassing the model. |
| 38 | */ |
| 39 | export async function sendDirectMemberMessage( |
| 40 | recipientName: string, |
| 41 | message: string, |
| 42 | teamContext: AppState['teamContext'], |
| 43 | writeToMailbox?: WriteToMailboxFn, |
| 44 | ): Promise<DirectMessageResult> { |
| 45 | if (!teamContext || !writeToMailbox) { |
| 46 | return { success: false, error: 'no_team_context' } |
| 47 | } |
| 48 | |
| 49 | // Find team member by name |
| 50 | const member = Object.values(teamContext.teammates ?? {}).find( |
| 51 | t => t.name === recipientName, |
| 52 | ) |
| 53 | |
| 54 | if (!member) { |
| 55 | return { success: false, error: 'unknown_recipient', recipientName } |
| 56 | } |
| 57 | |
| 58 | await writeToMailbox( |
| 59 | recipientName, |
| 60 | { |
| 61 | from: 'user', |
| 62 | text: message, |
| 63 | timestamp: new Date().toISOString(), |
| 64 | }, |
| 65 | teamContext.teamName, |
| 66 | ) |
| 67 | |
| 68 | return { success: true, recipientName } |
| 69 | } |
no test coverage detected