o
    &zh                     @   sZ   d dl mZ d dlmZ d dlmZ d dlmZ G dd deZG dd deZ	e	gZ
d	S )
    EmailAddress)ProviderAccount)NotionOAuth2Adapter)OAuth2Providerc                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )NotionAccountc                 C   s   | j jd d S )Nowneruseraccount
extra_dataself r   j/var/www/html/kangema/venv/lib/python3.10/site-packages/allauth/socialaccount/providers/notion/provider.pyget_user   s   zNotionAccount.get_userc                 C      |   d S )Nnamer   r   r   r   r   get_name      zNotionAccount.get_namec                 C   r   )N
avatar_urlr   r   r   r   r   get_avatar_url   r   zNotionAccount.get_avatar_urlc                 C      | j jd S )Nworkspace_namer
   r   r   r   r   get_workspace_name   r   z NotionAccount.get_workspace_namec                 C   r   )Nworkspace_iconr
   r   r   r   r   get_workspace_icon   r   z NotionAccount.get_workspace_iconc                 C   s    |   }|  }| d| dS )Nz ())r   r   )r   r   	workspacer   r   r   to_str   s   zNotionAccount.to_strN)	__name__
__module____qualname__r   r   r   r   r   r    r   r   r   r   r      s    r   c                   @   s4   e Zd ZdZdZeZeZdd Z	dd Z
dd Zd	S )
NotionProvidernotionNotionc                 C   s$   |d d d }|d }d||f S )z
        The unique identifier for Notion is a combination of the User ID
        and the Workspace ID they have authorized the application with.
        r   r	   idworkspace_idzuser-%s_workspace-%sr   )r   datauser_idr(   r   r   r   extract_uid#   s   zNotionProvider.extract_uidc                 C   s    |d d }|d d |d< |S )Nr   r	   personemailr   )r   r)   r	   r   r   r   extract_common_fields,   s   z$NotionProvider.extract_common_fieldsc                 C   s(   |d d }|d d }t |dddgS )Nr   r	   r,   r-   T)r-   verifiedprimaryr   )r   r)   r	   r-   r   r   r   extract_email_addresses1   s   z&NotionProvider.extract_email_addressesN)r!   r"   r#   r'   r   r   account_classr   oauth2_adapter_classr+   r.   r1   r   r   r   r   r$      s    	r$   N)allauth.account.modelsr   $allauth.socialaccount.providers.baser   ,allauth.socialaccount.providers.notion.viewsr   /allauth.socialaccount.providers.oauth2.providerr   r   r$   provider_classesr   r   r   r   <module>   s    
