Files
ACORE/apps/mattermost_connector/tasks.py
T
lokses 131cb27d16 Initial commit — ACORE pharmacy network management system
Django project: employees, locations, visit_manager, it_manager,
mattermost_connector and stub connectors (ad, mail, portal).
2026-05-31 14:21:47 +03:00

22 lines
865 B
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from celery import shared_task
from django.contrib.auth import get_user_model
Employee = get_user_model()
from apps.mattermost_connector.services.sync_service import sync_employee
import logging
logger = logging.getLogger(__name__)
@shared_task
def sync_employee_to_mattermost(employee_id):
"""
Асинхронная задача синхронизации сотрудника с Mattermost
"""
try:
employee = Employee.objects.get(id=employee_id)
sync_employee(employee)
logger.info(f"Задача синхронизации для {employee.email} выполнена")
except Employee.DoesNotExist:
logger.error(f"Сотрудник с ID {employee_id} не найден")
except Exception as e:
logger.error(f"Ошибка в задаче синхронизации: {e}")