Ë
    @gýjY  ã                   ó`   — d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZ  G d„ d«      Zy)	é    N)ÚOptional)ÚAsyncSession)ÚNotification)ÚNotificationRepository)ÚCreateNotificationRequestÚNotificationResponsec                   óÜ   — e Zd ZdZdefd„Zdej                  dede	fd„Z
	 ddej                  dedee	   fd	„Zdej                  d
eej                     defd„Zdej                  defd„Zy)ÚNotificationServicez;Manages system, billing, and broadcast event notifications.Údbc                 ó2   — || _         t        |«      | _        y ©N)r   r   Úrepo)Úselfr   s     ú4/root/telegram-saas/modules/notifications/service.pyÚ__init__zNotificationService.__init__   s   € ØˆŒÜ*¨2Ó.ˆ�	ó    Ú	tenant_idÚreqÚreturnc              ƒ   óî   K  — | j                   j                  ||j                  |j                  |j                  |j
                  |j                  ¬«      ƒ d {  –—† }t        j                  |«      S 7 Œ­w)N)r   ÚtitleÚmessageÚcategoryÚ
action_urlÚuser_id)	r   Úcreater   r   r   r   r   r   Úmodel_validate)r   r   r   Únotifs       r   Úcreate_notificationz'NotificationService.create_notification   sd   è ø€ ð
 —i‘i×&Ñ&ØØ—)‘)Ø—K‘KØ—\‘\Ø—~‘~Ø—K‘Kð 'ó 
÷ 
ˆô $×2Ñ2°5Ó9Ð9ð
ús   ‚AA5ÁA3ÁA5Úunread_onlyc              ƒ   ó¨   K  — | j                   j                  ||¬«      ƒ d {  –—† }|D �cg c]  }t        j                  |«      ‘Œ c}S 7 Œ'c c}w ­w)N)r    )r   Úlist_by_tenantr   r   )r   r   r    ÚnotifsÚns        r   Úlist_notificationsz&NotificationService.list_notifications"   sJ   è ø€ ð
 —y‘y×/Ñ/°	À{Ð/ÓS×SˆØ@FÖG¸1Ô$×3Ñ3°AÕ6ÒGÐGð TúÚGùs    ‚!A£A¤A¬AÁAÁAÚnotification_idsc              ƒ   óV   K  — | j                   j                  ||«      ƒ d {  –—† S 7 Œ­wr   )r   Ú	mark_read)r   r   r&   s      r   Úmark_notifications_readz+NotificationService.mark_notifications_read*   s&   è ø€ ð
 —Y‘Y×(Ñ(¨Ð4DÓE×EÐEÐEús   ‚ )¢'£)c              ƒ   óT   K  — | j                   j                  |«      ƒ d {  –—† S 7 Œ­wr   )r   Úcount_unread)r   r   s     r   Úget_unread_countz$NotificationService.get_unread_count1   s!   è ø€ Ø—Y‘Y×+Ñ+¨IÓ6×6Ð6Ð6ús   ‚(¡&¢(N)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚuuidÚUUIDr   r   r   ÚboolÚlistr%   Úintr)   r,   © r   r   r
   r
      s²   „ ÙEð/˜<ó /ð:à—9‘9ð:ð 'ð:ð 
ó	:ð$ "ñHà—9‘9ðHð ðHð 
Ð"Ñ	#ó	HðFà—9‘9ðFð ˜tŸy™y™/ðFð 
ó	Fð7°·	±	ð 7¸cô 7r   r
   )r1   Útypingr   Úsqlalchemy.ext.asyncior   Úmodules.notifications.modelsr   Ú modules.notifications.repositoryr   Úmodules.notifications.schemasr   r   r
   r6   r   r   ú<module>r<      s#   ðÛ Ý Ý /Ý 5Ý C÷÷&7ò &7r   