(body: SlackEvent)
| 4 | import { buildUserFromInfo } from '../serializers/buildUserFromInfo'; |
| 5 | |
| 6 | export async function processTeamJoin(body: SlackEvent) { |
| 7 | const event = body.event as SlackTeamJoinEvent; |
| 8 | const team_id = event.user.team_id; |
| 9 | // find account by slack team id |
| 10 | const account = await findAccountBySlackTeamId(team_id); |
| 11 | if (!account?.id) { |
| 12 | return { |
| 13 | status: 404, |
| 14 | error: 'Account not found', |
| 15 | metadata: { team_id }, |
| 16 | }; |
| 17 | } |
| 18 | const param = buildUserFromInfo(event.user, account.id); |
| 19 | await createUser(param); |
| 20 | return { |
| 21 | status: 201, |
| 22 | message: 'User created', |
| 23 | }; |
| 24 | } |
no test coverage detected