|
10 | 10 | from quivr_api.celery_config import celery
|
11 | 11 | from quivr_api.logger import get_logger
|
12 | 12 | from quivr_api.middlewares.auth import AuthBearer, get_current_user
|
13 |
| -from quivr_api.modules.sync.dto.inputs import SyncsUserInput, SyncUserUpdateInput |
| 13 | +from quivr_api.modules.sync.dto.inputs import ( |
| 14 | + SyncsUserInput, |
| 15 | + SyncsUserStatus, |
| 16 | + SyncUserUpdateInput, |
| 17 | +) |
14 | 18 | from quivr_api.modules.sync.service.sync_service import SyncService, SyncUserService
|
15 | 19 | from quivr_api.modules.user.entity.user_identity import UserIdentity
|
16 | 20 |
|
@@ -65,6 +69,7 @@ def authorize_notion(
|
65 | 69 | provider="Notion",
|
66 | 70 | credentials={},
|
67 | 71 | state={"state": state},
|
| 72 | + status=str(SyncsUserStatus.SYNCING), |
68 | 73 | )
|
69 | 74 | sync_user_service.create_sync_user(sync_user_input)
|
70 | 75 | return {"authorization_url": authorize_url}
|
@@ -145,15 +150,20 @@ def oauth2callback_notion(request: Request, background_tasks: BackgroundTasks):
|
145 | 150 |
|
146 | 151 | sync_user_input = SyncUserUpdateInput(
|
147 | 152 | credentials=result,
|
148 |
| - state={}, |
| 153 | + # state={}, |
149 | 154 | email=user_email,
|
| 155 | + status=str(SyncsUserStatus.SYNCING), |
150 | 156 | )
|
151 | 157 | sync_user_service.update_sync_user(current_user, state_dict, sync_user_input)
|
152 | 158 | logger.info(f"Notion sync created successfully for user: {current_user}")
|
153 | 159 | # launch celery task to sync notion data
|
154 | 160 | celery.send_task(
|
155 | 161 | "fetch_and_store_notion_files_task",
|
156 |
| - kwargs={"access_token": access_token, "user_id": current_user}, |
| 162 | + kwargs={ |
| 163 | + "access_token": access_token, |
| 164 | + "user_id": current_user, |
| 165 | + "sync_user_id": sync_user_state.id, |
| 166 | + }, |
157 | 167 | )
|
158 | 168 | return HTMLResponse(successfullConnectionPage)
|
159 | 169 |
|
|
0 commit comments