{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://objectsgrid.com/.well-known/objects-catalog/Message/v1/schema.json",
  "title": "Message",
  "description": "Objects Grid Message Object. One message of a Conversation. Its text is personal data: encrypted with its sender's Person key and erased with the sender. A private record: it has no JSON-LD document. Modeled in compliance with https://schema.org/Message.",
  "type": "object",
  "properties": {
    "at_context": {
      "description": "Schema context",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "https://schema.org"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_type": {
      "description": "The object type",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "Message"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_id": {
      "description": "This Message's ObjectsGrid URL, https://apis.objectsgrid.com/<path>/<id>: its JSON-LD @id, which References point to. Set by the service.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "readOnly": true
    },
    "id": {
      "description": "The unique identifier for Message. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "identifier": {
      "description": "The unique identifier for Message. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "url": {
      "description": "This Message URL. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "minLength": 1,
      "readOnly": true
    },
    "text": {
      "description": "What it says. Personal: encrypted with the Person key of the sender, when the sender is a Person, so erasing the sender erases it; the other side's messages stay readable.",
      "type": [
        "string",
        "null"
      ],
      "maxLength": 10000,
      "x-objectsgrid-personal": "person:sender"
    },
    "isPartOf": {
      "description": "The Conversation it belongs to",
      "x-objectsgrid-rangeIncludes": [
        "Conversation"
      ],
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
    },
    "sender": {
      "x-objectsgrid-erasure": "keep",
      "x-objectsgrid-version": "pinned",
      "description": "Who sent it: the URL of a Person or Organization, stored as <url>?version=<objectVersion>",
      "x-objectsgrid-rangeIncludes": [
        "Person",
        "Organization"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "recipient": {
      "x-objectsgrid-erasure": "keep",
      "x-objectsgrid-version": "pinned",
      "description": "Who it is for: URLs of Persons and Organizations, stored as <url>?version=<objectVersion>",
      "x-objectsgrid-rangeIncludes": [
        "Person",
        "Organization"
      ],
      "type": [
        "array",
        "null"
      ],
      "maxItems": 20,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
      }
    },
    "dateSent": {
      "description": "When it was sent; the time it was created when not given",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "dateRead": {
      "description": "When the recipient read it, set by the app",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "messageAttachment": {
      "description": "Attached files: URLs of files the app stores, as for images",
      "type": [
        "array",
        "null"
      ],
      "maxItems": 20,
      "items": {
        "type": "string",
        "format": "uri"
      }
    },
    "tags": {
      "description": "Tags an ABAC policy can decide on. A name may repeat; the same name and value appear once. Every stored object has them: created empty when not sent, kept by a replacement (PUT) that does not mention them, unchanged by a patch that does not mention them, cleared by null or [].",
      "type": "array",
      "default": [],
      "uniqueItems": true,
      "maxItems": 50,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Tag/v1/schema.json"
      }
    },
    "meta": {
      "description": "System-managed metadata for the object (version, audit fields). Assigned by the server.",
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ObjectMeta/v1/schema.json",
      "readOnly": true
    }
  },
  "required": [
    "isPartOf",
    "sender"
  ],
  "x-objectsgrid-jsonLd": false
}
