# Mx Puppet Skype is a Matrix <-> Skype bridge
# See: https://github.com/Sorunome/mx-puppet-skype

matrix_mx_puppet_skype_enabled: true

matrix_mx_puppet_skype_container_image_self_build: false

matrix_mx_puppet_skype_docker_image: "sorunome/mx-puppet-skype:latest"
matrix_mx_puppet_skype_docker_image_force_pull: "{{ matrix_mx_puppet_skype_docker_image.endswith(':latest') }}"

matrix_mx_puppet_skype_base_path: "{{ matrix_base_data_path }}/mx-puppet-skype"
matrix_mx_puppet_skype_config_path: "{{ matrix_mx_puppet_skype_base_path }}/config"
matrix_mx_puppet_skype_data_path: "{{ matrix_mx_puppet_skype_base_path }}/data"
matrix_mx_puppet_skype_docker_src_files_path: "{{ matrix_mx_puppet_skype_base_path }}/docker-src"

matrix_mx_puppet_skype_appservice_port: "8438"

matrix_mx_puppet_skype_homeserver_address: 'http://matrix-synapse:8008'
matrix_mx_puppet_skype_homeserver_domain: '{{ matrix_domain }}'
matrix_mx_puppet_skype_appservice_address: 'http://matrix-mx-puppet-skype:{{ matrix_mx_puppet_skype_appservice_port }}'

# A list of extra arguments to pass to the container
matrix_mx_puppet_skype_container_extra_arguments: []

# List of systemd services that matrix-puppet-skype.service depends on.
matrix_mx_puppet_skype_systemd_required_services_list: ['docker.service']

# List of systemd services that matrix-puppet-skype.service wants
matrix_mx_puppet_skype_systemd_wanted_services_list: []

matrix_mx_puppet_skype_appservice_token: ''
matrix_mx_puppet_skype_homeserver_token: ''

# Can be set to enable automatic double-puppeting via Shared Secret Auth (https://github.com/devture/matrix-synapse-shared-secret-auth).
matrix_mx_puppet_skype_login_shared_secret: ''

# Default configuration template which covers the generic use case.
# You can customize it by controlling the various variables inside it.
#
# For a more advanced customization, you can extend the default (see `matrix_mx_puppet_skype_configuration_extension_yaml`)
# or completely replace this variable with your own template.
matrix_mx_puppet_skype_configuration_yaml: |
  #jinja2: lstrip_blocks: "True"
  bridge:
    # Address for the bridge to bind to; if running as a Docker container, you
    # probably want 0.0.0.0 here
    bindAddress: 0.0.0.0
    # Port to host the bridge on which your homeserver will connect to
    port: {{ matrix_mx_puppet_skype_appservice_port }}
    # Name of your homeserver
    domain: {{ matrix_mx_puppet_skype_homeserver_domain }}
    # URL where the bridge can connect to your homeserver
    homeserverUrl: {{ matrix_mx_puppet_skype_homeserver_address }}
    # Optionally specify a different media URL used for the media store
    mediaURL: https://{{ matrix_server_fqn_matrix }}
    # This enabled automatic double-puppeting:
    # A map for shared secrets of the homeserver URL to the shared secret
    # See https://github.com/devture/matrix-synapse-shared-secret-auth
    #loginSharedSecretMap:
    #  yourserver.com: supersecretsharedsecret
    {% if matrix_mx_puppet_skype_login_shared_secret != '' %}
    loginSharedSecretMap:
      {{ matrix_mx_puppet_skype_homeserver_domain }}: {{ matrix_mx_puppet_skype_login_shared_secret }}
    {% endif %}
    # optionally override the display name of the bridge bot
    #displayname: Protocol Bot
    # optionally set the avatar of the bridge bot
    #avatarUrl: mxc://yourserver.com/somefile

  logging:
    # Log level of console output
    # Allowed values starting with most verbose:
    # silly, debug, verbose, info, warn, error
    console: info
    # Optionally, you can apply filters to the console logging
    #console:
    #  level: info
    #  enabled:
    #    - Store
    #  disabled:
    #    - PresenceHandler

    # Date and time formatting
    lineDateFormat: MMM-D HH:mm:ss.SSS
    # Logging files
    # Log files are rotated daily by default
    files:
      # Log file path
      - file: "/data/bridge.log"
        # Log level for this file
        # Allowed values starting with most verbose:
        # silly, debug, verbose, info, warn, error
        level: info
        # Date and time formatting
        datePattern: YYYY-MM-DD
        # Maximum number of logs to keep.
        # This can be a number of files or number of days.
        # If using days, add 'd' as a suffix
        maxFiles: 14d
        # Maximum size of the file after which it will rotate. This can be a
        # number of bytes, or units of kb, mb, and gb. If using the units, add
        # 'k', 'm', or 'g' as the suffix
        maxSize: 50m
        # Optionally enable/disable logging for certain modules
        #disabled:
        #  - PresenceHandler
        #  - module: bot-sdk-MatrixLiteClient
        #    regex: /_matrix/client/r0/presence/ # this regex needs to match to disable the log
        #enabled:
        #  - Store

  database:
    # Use Postgres as a database backend
    # If set, will be used instead of SQLite3
    # Connection string to connect to the Postgres instance
    # with username "user", password "pass", host "localhost" and database name "dbname".
    # Modify each value as necessary
    #connString: "postgres://user:pass@localhost/dbname?sslmode=disable"
    # Use SQLite3 as a database backend
    # The name of the database file
    filename: /data/database.db

  provisioning:
    # Regex of Matrix IDs allowed to use the puppet bridge
    whitelist:
      # Allow a specific user
      #- "@user:server\\.com"
      # Allow users on a specific homeserver
      - '@.*:{{ matrix_mx_puppet_skype_homeserver_domain | regex_escape }}'
      # Allow anyone
      #- ".*"
    # Regex of Matrix IDs forbidden from using the puppet bridge
    #blacklist:
      # Disallow a specific user
      #- "@user:server\\.com"
      # Disallow users on a specific homeserver
      #- "@.*:yourserver\\.com"

  presence:
    # Bridge online/offline status
    enabled: true
    # How often to send status to the homeserver in milliseconds
    interval: 500
    # if the im.vector.user_status state setting should be diabled
    #disableStatusState: false
    # A blacklist of remote user IDs for the im.vector.user_status state setting
    #statusStateBlacklist:
    # - baduser

  relay:
    # Regex of Matrix IDs to allow to use the relay mode
    # Same format as in provisioning
    whitelist:
      - '@.*:{{ matrix_mx_puppet_skype_homeserver_domain | regex_escape }}'
    #blacklist:
      #- "@user:yourserver\\.com"

  # Map certain homeserver URLs to the C-S API endpoint
  # Useful for double-puppeting if .well-known is unavailable for some reason
  #homeserverUrlMap:
  #  yourserver.com: http://localhost:1234

  namePatterns:
    # Override the protocols set default name patterns
    # Which variables are available depends on protocol implementation
    user: :name
    room: :name

  limits:
    # Up to how many users should be auto-joined on room creation? -1 to disable
    # Defaults to 200
    maxAutojoinUsers: 200
    # How long the delay between two autojoin users should be, in millisectonds.
    # Defaults to 5000
    roomUserAutojoinDelay: 5000

matrix_mx_puppet_skype_configuration_extension_yaml: |
  # Your custom YAML configuration goes here.
  # This configuration extends the default starting configuration (`matrix_mx_puppet_skype_configuration_yaml`).
  #
  # You can override individual variables from the default configuration, or introduce new ones.
  #
  # If you need something more special, you can take full control by
  # completely redefining `matrix_mx_puppet_skype_configuration_yaml`.

matrix_mx_puppet_skype_configuration_extension: "{{ matrix_mx_puppet_skype_configuration_extension_yaml|from_yaml if matrix_mx_puppet_skype_configuration_extension_yaml|from_yaml is mapping else {} }}"

# Holds the final configuration (a combination of the default and its extension).
# You most likely don't need to touch this variable. Instead, see `matrix_mx_puppet_skype_configuration_yaml`.
matrix_mx_puppet_skype_configuration: "{{ matrix_mx_puppet_skype_configuration_yaml|from_yaml|combine(matrix_mx_puppet_skype_configuration_extension, recursive=True) }}"

matrix_mx_puppet_skype_registration_yaml: |
  as_token: "{{ matrix_mx_puppet_skype_appservice_token }}"
  hs_token: "{{ matrix_mx_puppet_skype_homeserver_token }}"
  id: skype-puppet
  namespaces:
    users:
      - exclusive: true
        regex: '@_skypepuppet_.*:{{ matrix_mx_puppet_skype_homeserver_domain|regex_escape }}'
    rooms: []
    aliases:
      - exclusive: true
        regex: '#_skypepuppet_.*:{{ matrix_mx_puppet_skype_homeserver_domain|regex_escape }}'
  protocols: []
  rate_limited: false
  sender_localpart: _skypepuppet_bot
  url: {{ matrix_mx_puppet_skype_appservice_address }}

matrix_mx_puppet_skype_registration: "{{ matrix_mx_puppet_skype_registration_yaml|from_yaml }}"