
    h<                         d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	m
Z
mZ d dlmZmZmZmZmZ d dlmZmZ d dlmZ  G d	 d
e      Z G d de      Z G d de      Zy)    N)Enum)BytesIO)	MimeTypes)DictListOptionalUnion)	BaseModel
ConfigDictEmailStrfield_validatormodel_validator)Headers
UploadFile)	WrongFilec                   8    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZy)MultipartSubtypeEnumzr
    For more info about Multipart subtypes, visit:
    https://en.wikipedia.org/wiki/MIME#Multipart_subtypes
    mixeddigestalternativerelatedreportsigned	encryptedz	form-datazx-mixed-replace	byterangeN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   	form_datamixed_replacer        _/var/www/html/retail-simulation-api/retail/lib/python3.12/site-packages/fastapi_mail/schemas.pyr   r      s;    
 EFKGFFII%MIr#   r   c                       e Zd ZdZdZy)MessageTypeplainhtmlN)r   r   r   r'   r(   r"   r#   r$   r&   r&      s    EDr#   r&   c                   t   e Zd ZU ee   ed<   g Zeeee	e
f      ed<   dZe
ed<   dZeee
ef      ed<   dZee
   ed<   dZeeeee
f      ed<   g Zee   ed	<   g Zee   ed
<   g Zee   ed<   dZe
ed<   eed<   ej0                  Zeed<   dZee	   ed<    ed      d        Z ed      d        Z ed      Z y)MessageSchema
recipientsattachments subjectNbodyalternative_bodytemplate_bodyccbccreply_tozutf-8charsetsubtypemultipart_subtypeheadersc                 H   g }t               }|D ]  }d }t        |t              r<|j                         }d|vrt	        d      t        j                  |      }|d= |d   }t        |t              rt        j                  j                  |      rt        j                  |t        j                        r|j                  |      }t        |d      5 }t        j                  j                  |j                        \  }	}
|d   }d }|rt!        d|i      }t#        |j%                               }t'        |
||      }|j)                  ||f       d d d        Jt	        d      t        |t&              r|j)                  ||f       zt	        d	       |S # 1 sw Y   xY w)
Nfilezmissing "file" keyrbmoder   zcontent-type)filenamer:   r8   z2incorrect file path for attachment or not readablez<attachments field type incorrect, must be UploadFile or path)r   
isinstancedictkeysr   copystrospathisfileaccessR_OK
guess_typeopensplitnamer   r   readr   append)clsvtempmimer:   	file_metarA   	mime_typef_	file_namecontent_typer8   file_contentus                  r$   validate_filezMessageSchema.validate_file3   sn   {DI$%yy{%#$899 IIdO	f%F|$$77>>$'BIIdBGG,D $ 5Id.!')ww}}QVV'<9'0|"&'&-~|.L&MG'.qvvx'8&%.\7 Q	N3 /. $L  D*-T9-.R = B + /.s   A=FF!	afterr<   c                 f    |j                   t        j                  k7  r|j                  rd|_        |S )z1
        Validate alternative_body field
        N)r7   r   r   r0   )rO   valuess     r$   validate_alternative_bodyz'MessageSchema.validate_alternative_body[   s/     $$(<(H(HH''&*F#r#   T)arbitrary_types_allowed)!r   r   r   r   r   __annotations__r,   r	   r   r   rC   r.   r/   r   listr0   r1   r@   r2   r3   r4   r5   r&   r   r   r7   r8   r   r[   r   r_   r   model_configr"   r#   r$   r*   r*   $   s	   X68KeJc1238GS'+D(5d#
$+&*hsm*6:M8E$c/23:BXCh!Hd8n!GS.B.H.H+H"GXd^"]#% $%N '"	 #	 d;Lr#   r*   )rD   enumr   ior   	mimetypesr   typingr   r   r   r	   pydanticr
   r   r   r   r   starlette.datastructuresr   r   fastapi_mail.errorsr   r   r&   r*   r"   r#   r$   <module>rk      sI    	    . . V V 8 )4 $$ 
C<I C<r#   