# HG changeset patch # User Matthew Wild # Date 1702408108 0 # Node ID 174c77da03f55d15b53d265d294e763ce549620f # Parent e304e19536f21a83e4eba7ac5343b24d675df0a6 mod_server_info: New module to add custom service extension forms to disco diff -r e304e19536f2 -r 174c77da03f5 mod_server_info/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_server_info/README.md Tue Dec 12 19:08:28 2023 +0000 @@ -0,0 +1,50 @@ +--- +labels: +- 'Stage-Alpha' +summary: Manually configure extended service discovery info +... + +XEP-0128 defines a way for servers to provide custom information via service +discovery. Various XEPs and plugins make use of this functionality, so that +e.g. clients can look up necessary information. + +This module allows the admin to manually configure service discovery +extensions in the config file. It may be useful as a way to advertise certain +information. + +Everything configured here is publicly visible to other XMPP entities. + +## Configuration + +The `server_info` option accepts a list of dataforms. A dataform is an array +of fields. A field has three required properties: + +- `type` - usually `text-single` or `list-multi` +- `var` - the field name +- `value` the field value + +Example configuration: + +``` lua +server_info = { + + -- Our custom form + { + -- Conventionally XMPP dataforms have a 'FORM_TYPE' field to + -- indicate what type of form it is + { type = "hidden", var = "FORM_TYPE", value = "urn:example:foo" }; + + -- Advertise that our maximum speed is 88 mph + { type = "text-single", var = "speed", value = "88" }; + + -- Advertise that the time is 1:20 AM and zero seconds + { type = "text-single", var = "time", value = "01:21:00" }; + }; + +} +``` + +## Compatibility + +This module should be compatible with Prosody 0.12, and possibly earlier +versions. diff -r e304e19536f2 -r 174c77da03f5 mod_server_info/mod_server_info.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_server_info/mod_server_info.lua Tue Dec 12 19:08:28 2023 +0000 @@ -0,0 +1,18 @@ +-- XEP-0128: Service Discovery Extensions (manual config) +-- +-- Copyright (C) 2023 Matthew Wild +-- +-- This project is MIT/X11 licensed. Please see the +-- COPYING file in the source package for more information. +-- + +local dataforms = require "util.dataforms"; + +local config = module:get_option("server_info"); + +if not config or next(config) == nil then return; end -- Nothing to do + +for _, form in ipairs(config) do + module:add_extension(dataforms.new(form):form({}, "result")); +end +