Compare commits

...

3 Commits

4 changed files with 15 additions and 6 deletions

View File

@ -4,6 +4,9 @@ from app.models.task import Task
def success_state(task_id):
task = Task.query.get(task_id)
if not task:
return
task.status = "SUCCESS"
task.status_message = "задача выполнена успешно"
@ -12,6 +15,9 @@ def success_state(task_id):
def failure_state(task_id, exception):
task = Task.query.get(task_id)
if not task:
return
task.status = "FAILURE"
task.status_message = f"произошла ошибка {str(exception)}"
@ -20,6 +26,9 @@ def failure_state(task_id, exception):
def run_state(task_id, task_record_id):
task = Task.query.get(task_record_id)
if not task:
return
task.task_id = task_id
task.status = "RUNNING"
task.status_message = "задача запущена"

View File

@ -1,4 +1,4 @@
from sqlalchemy import Integer, null
from sqlalchemy import Integer, false, null
from sqlalchemy.schema import (
Column,
ForeignKey,
@ -16,7 +16,7 @@ class User(db.Model):
username: Mapped[str] = mapped_column(nullable=True)
description: Mapped[str] = mapped_column(nullable=True)
delete: Mapped[bool] = mapped_column(default="false")
delete: Mapped[bool] = mapped_column(default=false)
collection_id = Column(Integer, ForeignKey("collection.id"))
collection: Mapped["Collection"] = relationship("Collection", back_populates="users")

View File

@ -66,7 +66,7 @@ class PaperClient(TelegramClient):
except (PeerFloodError, FloodWaitError) as e:
raise FloodException(e)
except (UserChannelsTooMuchError, UsersTooMuchError, UserIsBlockedError, YouBlockedUserError, UserKickedError, UsernameInvalidError) as e:
except (UserChannelsTooMuchError, UsersTooMuchError, UserIsBlockedError, YouBlockedUserError, ValueError, UserKickedError, UsernameInvalidError) as e:
raise IgnoreException(e)
@logger.catch(reraise=True)

View File

@ -25,8 +25,8 @@ class PaperParser:
for user in users:
try:
if task.is_aborted():
return self.users_to_delete
return
await self.client.invite_user(user, group)
except (UserPrivacyException, IgnoreException):
@ -50,7 +50,7 @@ class PaperParser:
for user in users:
try:
if task.is_aborted():
return self.users_to_delete
return
await self.client.send_message(user, message, file)