def create_invited_org_user(organisation, invited_by, email_address='*****@*****.**'): invited_org_user = InvitedOrganisationUser( email_address=email_address, invited_by=invited_by, organisation=organisation, ) save_invited_org_user(invited_org_user) return invited_org_user
def invite_user_to_org(organisation_id): data = request.get_json() validate(data, post_create_invited_org_user_status_schema) invited_org_user = InvitedOrganisationUser( email_address=data["email_address"], invited_by_id=data["invited_by"], organisation_id=organisation_id, ) save_invited_org_user(invited_org_user) template = dao_get_template_by_id( current_app.config["ORGANISATION_INVITATION_EMAIL_TEMPLATE_ID"]) saved_notification = persist_notification( template_id=template.id, template_version=template.version, recipient=invited_org_user.email_address, service=template.service, personalisation={ "user_name": invited_org_user.invited_by.name, "organisation_name": invited_org_user.organisation.name, "url": invited_org_user_url( invited_org_user.id, data.get("invite_link_host"), ), }, notification_type=EMAIL_TYPE, api_key_id=None, key_type=KEY_TYPE_NORMAL, reply_to_text=invited_org_user.invited_by.email_address, ) send_notification_to_queue(saved_notification, research_mode=False, queue=QueueNames.NOTIFY) return jsonify(data=invited_org_user.serialize()), 201
def invite_user_to_org(organisation_id): data = request.get_json() validate(data, post_create_invited_org_user_status_schema) invited_org_user = InvitedOrganisationUser( email_address=data['email_address'], invited_by_id=data['invited_by'], organisation_id=organisation_id) save_invited_org_user(invited_org_user) template = dao_get_template_by_id( current_app.config['ORGANISATION_INVITATION_EMAIL_TEMPLATE_ID']) saved_notification = persist_notification( template_id=template.id, template_version=template.version, recipient=invited_org_user.email_address, service=template.service, personalisation={ 'user_name': ('The Catalyst Notify team' if invited_org_user.invited_by.platform_admin else invited_org_user.invited_by.name), 'organisation_name': invited_org_user.organisation.name, 'url': invited_org_user_url( invited_org_user.id, data.get('invite_link_host'), ), }, notification_type=EMAIL_TYPE, api_key_id=None, key_type=KEY_TYPE_NORMAL, reply_to_text=invited_org_user.invited_by.email_address) send_notification_to_queue(saved_notification, research_mode=False, queue=QueueNames.NOTIFY) return jsonify(data=invited_org_user.serialize()), 201