plugins/mod_server_contact_info.lua
author Kim Alvefur <zash@zash.se>
Fri, 24 Mar 2023 16:29:48 +0100
changeset 12985 d795e3bbc0e3
parent 12981 74b9e05af71e
child 13441 1ba323d6f35c
permissions -rw-r--r--
mod_server_contact_info: Reorder dataform keys for more aligned view
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8260
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     1
-- XEP-0157: Contact Addresses for XMPP Services for Prosody
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     2
--
9337
a86736e0163c mod_server_contact_info: Update copyright header
Kim Alvefur <zash@zash.se>
parents: 9336
diff changeset
     3
-- Copyright (C) 2011-2018 Kim Alvefur
8260
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     4
--
9337
a86736e0163c mod_server_contact_info: Update copyright header
Kim Alvefur <zash@zash.se>
parents: 9336
diff changeset
     5
-- This project is MIT/X11 licensed. Please see the
a86736e0163c mod_server_contact_info: Update copyright header
Kim Alvefur <zash@zash.se>
parents: 9336
diff changeset
     6
-- COPYING file in the source package for more information.
8260
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     7
--
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     8
12981
74b9e05af71e plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents: 11588
diff changeset
     9
local array = require "prosody.util.array";
12985
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    10
local dataforms = require "prosody.util.dataforms";
12981
74b9e05af71e plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents: 11588
diff changeset
    11
local jid = require "prosody.util.jid";
11588
8bea29d1f82d mod_server_contact_info: Generate properly escaped URIs from 'admins'
Kim Alvefur <zash@zash.se>
parents: 11587
diff changeset
    12
local url = require "socket.url";
8260
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    13
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    14
-- Source: http://xmpp.org/registrar/formtypes.html#http:--jabber.org-network-serverinfo
12985
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    15
local form_layout = dataforms.new({
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    16
	{ var = "FORM_TYPE"; type = "hidden"; value = "http://jabber.org/network/serverinfo" };
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    17
	{ type = "list-multi"; name = "abuse"; var = "abuse-addresses" };
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    18
	{ type = "list-multi"; name = "admin"; var = "admin-addresses" };
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    19
	{ type = "list-multi"; name = "feedback"; var = "feedback-addresses" };
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    20
	{ type = "list-multi"; name = "sales"; var = "sales-addresses" };
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    21
	{ type = "list-multi"; name = "security"; var = "security-addresses" };
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    22
	{ type = "list-multi"; name = "status"; var = "status-addresses" };
d795e3bbc0e3 mod_server_contact_info: Reorder dataform keys for more aligned view
Kim Alvefur <zash@zash.se>
parents: 12981
diff changeset
    23
	{ type = "list-multi"; name = "support"; var = "support-addresses" };
9336
fd704adc62e1 mod_server_contact_info: Simplify
Kim Alvefur <zash@zash.se>
parents: 8260
diff changeset
    24
});
8260
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    25
9431
8e7feec95e8d mod_server_contact_info: Comment on fallback to using 'admins'
Kim Alvefur <zash@zash.se>
parents: 9337
diff changeset
    26
-- JIDs of configured service admins are used as fallback
9336
fd704adc62e1 mod_server_contact_info: Simplify
Kim Alvefur <zash@zash.se>
parents: 8260
diff changeset
    27
local admins = module:get_option_inherited_set("admins", {});
8260
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    28
9336
fd704adc62e1 mod_server_contact_info: Simplify
Kim Alvefur <zash@zash.se>
parents: 8260
diff changeset
    29
local contact_config = module:get_option("contact_info", {
11588
8bea29d1f82d mod_server_contact_info: Generate properly escaped URIs from 'admins'
Kim Alvefur <zash@zash.se>
parents: 11587
diff changeset
    30
	admin = array.collect(admins / jid.prep / function(admin) return url.build({scheme = "xmpp"; path = admin}); end);
9336
fd704adc62e1 mod_server_contact_info: Simplify
Kim Alvefur <zash@zash.se>
parents: 8260
diff changeset
    31
});
8260
c24837f57259 mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    32
9336
fd704adc62e1 mod_server_contact_info: Simplify
Kim Alvefur <zash@zash.se>
parents: 8260
diff changeset
    33
module:add_extension(form_layout:form(contact_config, "result"));