diff --git a/main.py b/main.py index 8796d22..c484df4 100644 --- a/main.py +++ b/main.py @@ -401,7 +401,7 @@ If due to any reason you can not participate, please just change your "👍" rea print(emoji, "direct", source, isRemove) - def create_or_update_task_group(self, task: Task) -> Result[str, str]: + def create_or_update_task_group(self, task: Task) -> Result[None, str]: chatgroup = task.chatgroup # Check if the group still exists @@ -423,8 +423,16 @@ If due to any reason you can not participate, please just change your "👍" rea chatgroup = create_result.unwrap().id task.chatgroup = chatgroup - self.api.update_group_members(chatgroup, [r.user.name for r in task.accepted_requests()]) - self.api.update_group_admins(chatgroup, [r.user.name for r in task.accepted_requests()]) + + update_members_result = self.api.update_group_members(chatgroup, [r.user.name for r in task.accepted_requests()]) + if is_err(update_members_result): + return Err(update_members_result.unwrap_err()) + + update_group_admins = self.api.update_group_admins(chatgroup, [r.user.name for r in task.accepted_requests()]) + if is_err(update_group_admins): + return Err(update_group_admins.unwrap_err()) + + return Ok(None) async def sync_members_and_tasks(self, session: Session): # Async routine that syncs active members using sync_members_as_active_users(), @@ -442,6 +450,11 @@ If due to any reason you can not participate, please just change your "👍" rea print(sync_result.unwrap_err()) for task in get_active_tasks(session, now()): + create_or_update_result = self.create_or_update_task_group(task) + if is_err(create_or_update_result): + print(create_or_update_result.unwrap_err()) + continue + reqs = task.create_additional_requests(now(), session) if is_err(reqs): @@ -482,8 +495,6 @@ You have time to answer for {format_seconds(task.timeout)}.""" recipients=[request.user.name]) res = self.api.send_message(message) - self.create_or_update_task_group(task) - session.commit() await asyncio.sleep(1)