diff --git a/app/blueprints/api/tasks/tasks.py b/app/blueprints/api/tasks/tasks.py index 224e97f..4940298 100644 --- a/app/blueprints/api/tasks/tasks.py +++ b/app/blueprints/api/tasks/tasks.py @@ -3,7 +3,7 @@ import time from celery import shared_task import asyncio -from telethon.tl.types import UserStatusOnline, UserStatusOffline +from telethon.tl.types import UserStatusOnline, UserStatusOffline, UserStatusRecently from app.models.user import User from paper.parser import PaperParser @@ -60,9 +60,11 @@ def parse_users_task(self, task_id: int): is_active = False if isinstance(user.status, UserStatusOffline): - is_active = user.status.was_online + datetime.timedelta(day=5) >= datetime.now() + was_online = user.status.was_online.replace(tzinfo=datetime.timezone.utc) + today = datetime.datetime.today().replace(tzinfo=datetime.timezone.utc) + is_active = was_online + datetime.timedelta(days=5) >= today - if isinstance(user.status, UserStatusOnline): + if isinstance(user.status, UserStatusOnline) or isinstance(user.status, UserStatusRecently): is_active = True if not is_active: