import { IAddOrInviteContext , IAddOrInviteResponse } from "../types" ; import { handleNoUsers } from "./handle-no-users" ; import { processAutoAddUsers } from "./process-auto-add-users" ; import { processInviteUsers } from "./process-invite-users" ; private export param { IAddOrInviteContext } context return { IAddOrInviteResponse } export async function addOrInviteCommunityUsers ( context ) { let fnToCall = handleNoUsers ; let shouldEmail = false ; if ( context . community && context . community . length > 0 ) { fnToCall = context . canAutoAddUser ? processAutoAddUsers : processInviteUsers ; if ( context . email ) { if ( context . email . hasOwnProperty ( "groupId" ) ) { if ( context . email . groupId === context . groupId ) { fnToCall = processAutoAddUsers ; shouldEmail = true ; } } else { fnToCall = processAutoAddUsers ; shouldEmail = true ; } } } return fnToCall ( context , "community" , shouldEmail ) ; }