def update(*, db_session, task: Task, task_in: TaskUpdate, sync_external: bool=True) -> Task:
    'Update an existing task.'
    assignees = []
    for i in task_in.assignees:
        assignees.append(incident_flows.incident_add_or_reactivate_participant_flow(db_session=db_session, incident_id=task.incident.id, user_email=i.individual.email))
    task.assignees = assignees
    if task_in.owner:
        task.owner = incident_flows.incident_add_or_reactivate_participant_flow(db_session=db_session, incident_id=task.incident.id, user_email=task_in.owner.individual.email)
    update_data = task_in.dict(skip_defaults=True, exclude={'assignees', 'owner', 'creator', 'incident', 'tickets'})
    for field in update_data.keys():
        setattr(task, field, update_data[field])
    drive_task_plugin = plugin_service.get_active(db_session=db_session, plugin_type='task')
    if drive_task_plugin:
        if sync_external:
            try:
                if task.incident.incident_document:
                    file_id = task.incident.incident_document.resource_id
                    drive_task_plugin.instance.update(file_id, task.resource_id, resolved=task.status)
            except Exception:
                if task.incident.incident_review_document:
                    file_id = task.incident.incident_review_document.resource_id
                    drive_task_plugin.instance.update(file_id, task.resource_id, resolved=task.status)
    db_session.add(task)
    db_session.commit()
    return task
Update an existing task.
def update(*, db_session, task: Task, task_in: TaskUpdate, sync_external: bool=True) -> Task:
    
    assignees = []
    for i in task_in.assignees:
        assignees.append(incident_flows.incident_add_or_reactivate_participant_flow(db_session=db_session, incident_id=task.incident.id, user_email=i.individual.email))
    task.assignees = assignees
    if task_in.owner:
        task.owner = incident_flows.incident_add_or_reactivate_participant_flow(db_session=db_session, incident_id=task.incident.id, user_email=task_in.owner.individual.email)
    update_data = task_in.dict(skip_defaults=True, exclude={'assignees', 'owner', 'creator', 'incident', 'tickets'})
    for field in update_data.keys():
        setattr(task, field, update_data[field])
    drive_task_plugin = plugin_service.get_active(db_session=db_session, plugin_type='task')
    if drive_task_plugin:
        if sync_external:
            try:
                if task.incident.incident_document:
                    file_id = task.incident.incident_document.resource_id
                    drive_task_plugin.instance.update(file_id, task.resource_id, resolved=task.status)
            except Exception:
                if task.incident.incident_review_document:
                    file_id = task.incident.incident_review_document.resource_id
                    drive_task_plugin.instance.update(file_id, task.resource_id, resolved=task.status)
    db_session.add(task)
    db_session.commit()
    return task