{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "message.schema.json",
    "title": "message",
    "type": "object",
    "description": "Сообщение в переписке",
    "properties": {
        "Id": {
            "description": "Идентификатор сообщения",
            "type": "string",
            "format": "uuid"
        },
        "sentAt": {
            "description": "Дата и время отправки сообщения",
            "type": "string",
            "format": "date-time"
        },
        "sentBy": {
            "description": "Пользователь отправивший сообщение",
            "$ref": "user.schema.json"
        },
        "type": {
            "description": "Тип сообщения: TEXT-обычное сообщение, FILE-отправка файла, BACKWARD-автосообщение при возвратах",
            "enum": [
                "TEXT",
                "FILE",
                "BACKWARD"
            ]
        },
        "text": {
            "description": "Текст сообщения. Пустой если messageType = FILE ",
            "type": "string"
        },
        "isPrivate": {
            "description": "Признак приватного сообщения",
            "type": "boolean"
        },
        "isRead": {
            "description": "Признак, что сообщение прочитано второй стороной",
            "type": "boolean"
        },
        "notReadBy": {
            "description": "Кем не прочитано. Исходя из этих отметок определяется  и \"есть ли у пользователя непрочитанное сообщение\"",
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "role": {
                        "$ref": "common/_common.schema.json#/userRole"
                    },
                    "isNotificationSent":
                    {
                        "description": "Уведомление отправлено",
                        "type":  "boolean"
                    }
                }
            }
        },
        "hasReply": {
            "description": "Признак что на сообщение есть ответ",
            "type": "boolean",
            "format": "uuid"
        },
        "replyForId": {
            "description": "Идентификатор сообщения, для которого текущее является ответом",
            "type": "string",
            "format": "uuid"
        },
        "file": {
            "type": "object",
            "properties": {
                "path": {
                    "description": "Путь к сохраненному файлу",
                    "type": "string"
                },
                "name": {
                    "description": "отображаемое название файла",
                    "type": "string"
                },
                "size": {
                    "description": "Отображаемый размер файла",
                    "type": "in64"
                }
            }
        },
        "links": {
            "description": "Ссылки из сообщения",
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "url": {
                        "description": "URL адрес",
                        "type": "string"
                   }
                }
            }
        }
    }
}