Compare commits
3 Commits
8570dda211
...
da4dddbcf7
Author | SHA1 | Date |
---|---|---|
Анатолий Богомолов | da4dddbcf7 | |
Анатолий Богомолов | 16dc839a1f | |
Анатолий Богомолов | 66178acebe |
|
@ -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 = "задача запущена"
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -25,7 +25,7 @@ class PaperParser:
|
|||
for user in users:
|
||||
try:
|
||||
if task.is_aborted():
|
||||
return self.users_to_delete
|
||||
return
|
||||
|
||||
await self.client.invite_user(user, group)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue