"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._processPrimaryEmail = _processPrimaryEmail;
const get_prop_1 = require("../../../objects/get-prop");
const _is_org_admin_1 = require("../utils/_is-org-admin");
const emailOrgUsers_1 = require("../../emailOrgUsers");
/**
 * @private
 *
 * Send email notification if an email object is present and
 * the previous invitation call was successful
 */
function _processPrimaryEmail(context) {
    let response = Promise.resolve(context);
    // Email users if invite succeeds
    if (context.email && (0, get_prop_1.getProp)(context, "inviteResult.success")) {
        response = (0, emailOrgUsers_1.emailOrgUsers)(context.usersToEmail, context.email, context.primaryRO.authentication, (0, _is_org_admin_1._isOrgAdmin)(context.requestingUser)).then((result) => {
            context.primaryEmailResult = result;
            return context;
        });
    }
    return response;
}
//# sourceMappingURL=_process-primary-email.js.map