Merge remote-tracking branch 'origin/main' - resolve conflict
- Resolved conflict in app/social/services.py - Kept token auto-refresh logic with now() function for timezone support Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
commit
40afe9392c
18 files changed
+410
-53
No files matched your search
@@ -6,10 +6,12 @@ Social Account Service
|
||||
|
||||
import logging
|
||||
import secrets
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import timedelta
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import select
|
||||
|
||||
from app.utils.timezone import now
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from redis.asyncio import Redis
|
||||
@@ -305,7 +307,7 @@ class SocialAccountService:
|
||||
if account.token_expires_at is None:
|
||||
should_refresh = True
|
||||
else:
|
||||
buffer_time = datetime.now() + timedelta(hours=1)
|
||||
buffer_time = now() + timedelta(hours=1)
|
||||
if account.token_expires_at <= buffer_time:
|
||||
should_refresh = True
|
||||
|
||||
@@ -512,7 +514,7 @@ class SocialAccountService:
|
||||
)
|
||||
should_refresh = True
|
||||
else:
|
||||
buffer_time = datetime.now() + timedelta(minutes=10)
|
||||
buffer_time = now() + timedelta(minutes=10)
|
||||
if account.token_expires_at <= buffer_time:
|
||||
logger.info(
|
||||
f"[SOCIAL] 토큰 만료 임박, 갱신 시작 - account_id: {account.id}"
|
||||
@@ -571,7 +573,7 @@ class SocialAccountService:
|
||||
if token_response.refresh_token:
|
||||
account.refresh_token = token_response.refresh_token
|
||||
if token_response.expires_in:
|
||||
account.token_expires_at = datetime.now() + timedelta(
|
||||
account.token_expires_at = now() + timedelta(
|
||||
seconds=token_response.expires_in
|
||||
)
|
||||
|
||||
@@ -632,7 +634,7 @@ class SocialAccountService:
|
||||
# 토큰 만료 시간 계산
|
||||
token_expires_at = None
|
||||
if token_response.expires_in:
|
||||
token_expires_at = datetime.now() + timedelta(
|
||||
token_expires_at = now() + timedelta(
|
||||
seconds=token_response.expires_in
|
||||
)
|
||||
|
||||
@@ -685,7 +687,7 @@ class SocialAccountService:
|
||||
if token_response.refresh_token:
|
||||
account.refresh_token = token_response.refresh_token
|
||||
if token_response.expires_in:
|
||||
account.token_expires_at = datetime.now() + timedelta(
|
||||
account.token_expires_at = now() + timedelta(
|
||||
seconds=token_response.expires_in
|
||||
)
|
||||
if token_response.scope:
|
||||
@@ -701,7 +703,7 @@ class SocialAccountService:
|
||||
|
||||
# 재연결 시 연결 시간 업데이트
|
||||
if update_connected_at:
|
||||
account.connected_at = datetime.now()
|
||||
account.connected_at = now()
|
||||
|
||||
await session.commit()
|
||||
await session.refresh(account)
|
||||
|
||||
@@ -7,11 +7,12 @@ Social Upload Background Task
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
import aiofiles
|
||||
|
||||
from app.utils.timezone import now
|
||||
import httpx
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
@@ -70,7 +71,7 @@ async def _update_upload_status(
|
||||
if error_message:
|
||||
upload.error_message = error_message
|
||||
if status == UploadStatus.COMPLETED:
|
||||
upload.uploaded_at = datetime.now()
|
||||
upload.uploaded_at = now()
|
||||
|
||||
await session.commit()
|
||||
logger.info(
|
||||
|
||||
Reference in new issue
Block a user