From 28dad77a80fc748b1805d6929fd768910c967adc Mon Sep 17 00:00:00 2001 From: winet Date: Sun, 10 Mar 2024 00:29:25 +1000 Subject: [PATCH] fixed filters --- app/blueprints/api/tasks/tasks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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: