HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/buyercall/blueprints/sms/__pycache__/tasks.cpython-310.pyc
o

�we�
�@s�ddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlZddl
Z
ddlmZddlmZddlmZmZdd	lmZdd
lmZee�Zejdd��Zejd
d��ZdS)�N)�create_celery_app)�_try_renderer_template)�send_ses_email)�Key)�current_app)�lazy_gettext)�PartnershipAccount�Partnership)�Contact)�format_phone_numberc	Ks�|�dd�d}|dvrd|}nd}t��j}zd�|||d|�}Wt�d�nt�d�wtjd	}	d
dl	m
}
|
||	||�}t�|�|S)z, Upload the given MMS Image file to S3.
    �.�)�jpg�jpeg�png�tiff�tif�bmpzimage/zapplication/octet-streamz{}_{}/{}_{}_{}�mmsz(Could not set key for mms attachment url�
MMS_BUCKETr)�upload_file)
�rsplit�uuid�uuid4�hex�format�log�debug�celery�conf�buyercall.lib.util_boto3_s3r�os�remove)�partner_name�partnership_account_id�	file_name�	file_path�kwargs�file_extension�content_type�	hex_value�key�bucketr�mms_url�r.�@/home/arjun/projects/buyercall/buyercall/blueprints/sms/tasks.py�upload_mms_images


�

r0c
KsVtj�tj|k���}tj�tj|jk���}|j}|j}	|�	�}
t
|
�dd��}|
�dd�}tj�tj
|k��tj|k���}
|
rZt�d�|
j��d�|
j|
j�}|
j}|
j
}nt�d�|��d}d}|}t�}|�|�||||	||||d�}ztd
d	d
i|��}t||jd|d�WdSty�}zt�t���WYd}~dSd}~ww)N�From��Bodyz3The contact lead id that triggered the email is: {}z{} {}z+There is no contact yet for phone number {})�name�body�company�partner_logo�	lead_name�
lead_email�lead_number�lead_message�sms/mail/sms_rule_email�ext�htmlzAn Email triggered by an SMS)�
recipients�p_id�subjectr>)r<)r�query�filter�id�firstr	�partnership_idr4�logo�to_dictr�getr
�
phonenumber_1r$r�infor�	firstname�lastname�email�list�appendrr�	Exception�error�	traceback�
format_exc)�
email_address�
email_name�
email_bodyr$�leadr'�partner_account�partner�partnership_name�partnership_logo�new_lead�msg_lead_phone�
msg_lead_body�contact_lead�
msg_lead_name�msg_lead_email�msg_lead_number�email_to�ctx�sms_rule_email_template�er.r.r/�send_sms_rule_email*sR�
����rh)r!�loggingrrS�
buyercall.appr�buyercall.lib.flask_mailplusr�buyercall.lib.util_ses_emailr�boto.s3.keyr�botor�flaskr�flask_babelr�_�'buyercall.blueprints.partnership.modelsrr	�$buyercall.blueprints.contacts.modelsr
�buyercall.blueprints.filtersrr�taskr0rhr.r.r.r/�<module>s&