1
- from uuid import UUID
2
1
from sqlalchemy .ext .asyncio import AsyncSession
3
- from taskiq import TaskiqDepends
2
+ from taskiq_dependencies import Depends
4
3
5
4
from ...db import get_async_session
6
5
from ...email import sender
9
8
10
9
from ...models import User
11
10
11
+
12
12
@broker .task
13
13
async def send_reset_password_email (
14
- user_id : UUID ,
15
- session : AsyncSession = TaskiqDepends (get_async_session )
14
+ user_id : str ,
15
+ session : AsyncSession = Depends (get_async_session )
16
16
) -> None :
17
17
user = await User .get (session , user_id )
18
18
19
19
# Create a verification code, this is available
20
- # only at the time of calling this
20
+ # only at the time of calling this
21
21
reset_password_token = await user .get_verification_token (session )
22
22
23
23
sender .send (
@@ -32,16 +32,17 @@ async def send_reset_password_email(
32
32
},
33
33
)
34
34
35
+
35
36
@broker .task
36
37
async def send_account_verification_email (
37
- user_id : UUID ,
38
- session : AsyncSession = TaskiqDepends (get_async_session )
38
+ user_id : str ,
39
+ session : AsyncSession = Depends (get_async_session )
39
40
) -> None :
40
41
41
42
user = await User .get (session , user_id )
42
43
43
44
# Create a verification code, this is available
44
- # only at the time of calling this
45
+ # only at the time of calling this
45
46
verification_token = await user .get_verification_token (session )
46
47
47
48
sender .send (
@@ -56,25 +57,27 @@ async def send_account_verification_email(
56
57
},
57
58
)
58
59
60
+
59
61
@broker .task
60
62
async def send_welcome_email (
61
- user_id : UUID ,
62
- session : AsyncSession = TaskiqDepends (get_async_session )
63
+ user_id : str ,
64
+ session : AsyncSession = Depends (get_async_session )
63
65
) -> None :
64
66
user = await User .get (session , user_id )
65
67
66
68
67
69
@broker .task
68
70
async def send_otp_sms (
69
- user_id : UUID ,
70
- session : AsyncSession = TaskiqDepends (get_async_session )
71
+ user_id : str ,
72
+ session : AsyncSession = Depends (get_async_session )
71
73
) -> None :
72
74
user = await User .get (session , user_id )
73
75
76
+
74
77
@broker .task
75
78
async def send_otp_email (
76
- user_id : UUID ,
77
- session : AsyncSession = TaskiqDepends (get_async_session )
79
+ user_id : str ,
80
+ session : AsyncSession = Depends (get_async_session )
78
81
) -> None :
79
82
"""
80
83
Generates the OTP for a user and email it to them
@@ -85,8 +88,8 @@ async def send_otp_email(
85
88
user = await User .get (session , user_id )
86
89
87
90
otp = user .get_otp (
88
- digits = settings .verbosity .totp_length ,
89
- timeout = settings .lifetime .totp_token ,
91
+ digits = settings .verbosity .totp_length ,
92
+ timeout = settings .lifetime .totp_token ,
90
93
)
91
94
92
95
sender .send (
@@ -99,5 +102,3 @@ async def send_otp_email(
99
102
"user" : user ,
100
103
},
101
104
)
102
-
103
-
0 commit comments