import { ArcGISRequestError } from "@esri/arcgis-rest-request" ; import { IUser } from "@esri/arcgis-rest-types" ; import { getProp , emailOrgUsers } from "@esri/hub-common" ; import { IAddOrInviteContext , IAddOrInviteResponse } from "../types" ; private export param { IAddOrInviteContext } context return { IAddOrInviteResponse } export async function processEmailUsers ( context ) { const users = getProp ( context , "community" ) ; const notEmailed = [ ] ; let errors = [ ] ; for ( const user of users ) { const emailResponse = await emailOrgUsers ( [ user ] , getProp ( context , "email.message" ) , getProp ( context , "email.auth" ) , true ) ; if ( ! emailResponse . success ) { notEmailed . push ( user . username ) ; if ( emailResponse . errors ) { errors = errors . concat ( emailResponse . errors ) ; } } } return { users : users . map ( ( u ) => u . username ) , notEmailed , errors , notInvited : [ ] , notAdded : [ ] , } ; }