* Get user info for author display
(userId: string)
| 325 | * Get user info for author display |
| 326 | */ |
| 327 | async function getUserInfo(userId: string): Promise<{ name: string } | null> { |
| 328 | const pool = getPool(); |
| 329 | const result = await pool.query( |
| 330 | `SELECT first_name, last_name, email FROM users WHERE workos_user_id = $1`, |
| 331 | [userId] |
| 332 | ); |
| 333 | if (result.rows.length === 0) return null; |
| 334 | const user = result.rows[0]; |
| 335 | const name = user.first_name && user.last_name |
| 336 | ? `${user.first_name} ${user.last_name}` |
| 337 | : user.email?.split('@')[0] || 'Unknown'; |
| 338 | return { name }; |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * User context for direct function calls (from Addie or other internal services) |
no test coverage detected