# Copyright 2022 The Matrix.org Foundation C.I.C
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

type: object
title: Registration
properties:
  id:
    type: string
    description: A unique, user-defined ID of the application service which will never change.
  url:
    type: string
    description: The URL for the application service. May include a path after the domain name. Optionally set to null if no traffic is required.
  as_token:
    type: string
    description: A secret token that the application service will use to authenticate requests to the homeserver.
  hs_token:
    type: string
    description: A secret token that the homeserver will use authenticate requests to the application service.
  sender_localpart:
    type: string
    description: |-
      The localpart of the user associated with the application service. Events will be sent to the AS if this user is the target of the event, or
      is a joined member of the room where the event occurred.
  namespaces:
    type: object
    title: Namespaces
    description: The namespaces that the application service is interested in.
    properties:
      users:
        allOf:
          - $ref: namespace_list.yaml
          - description: |-
              A list of namespaces defining the user IDs that the application
              service is interested in, in addition to its `sender_localpart`.
              Events will be sent to the AS if a local user matching one of the
              namespaces is the target of the event, or is a joined member of
              the room where the event occurred.
      rooms:
        allOf:
          - $ref: namespace_list.yaml
          - description: |-
              A list of namespaces defining the room IDs that the application
              service is interested in. All events sent in a room with an ID
              which matches one of the namespaces will be sent to the AS.
      aliases:
        allOf:
          - $ref: namespace_list.yaml
          - description: |-
              A list of namespaces defining the room aliases that the application
              service is interested in. All events sent in a room with an alias
              which matches one of the namespaces will be sent to the AS.
  rate_limited:
    type: boolean
    description: Whether requests from masqueraded users are rate-limited. The sender is excluded.
  protocols:
    type: array
    description: The external protocols which the application service provides (e.g. IRC).
    items:
      type: string
required:
  - id
  - url
  - as_token
  - hs_token
  - sender_localpart
  - namespaces
