Fix tabs and indentations in metronome

This commit is contained in:
Salamandar 2024-08-31 10:18:39 +02:00 committed by Salamandar
parent 5b37936d11
commit e3ddb1dc4d
6 changed files with 320 additions and 321 deletions

View file

@ -1,28 +1,28 @@
VirtualHost "{{ domain }}" VirtualHost "{{ domain }}"
enable = true enable = true
ssl = { ssl = {
key = "/etc/yunohost/certs/{{ domain }}/key.pem"; key = "/etc/yunohost/certs/{{ domain }}/key.pem";
certificate = "/etc/yunohost/certs/{{ domain }}/crt.pem"; certificate = "/etc/yunohost/certs/{{ domain }}/crt.pem";
} }
authentication = "ldap2" authentication = "ldap2"
ldap = { ldap = {
hostname = "localhost", hostname = "localhost",
user = { user = {
basedn = "ou=users,dc=yunohost,dc=org", basedn = "ou=users,dc=yunohost,dc=org",
filter = "(&(objectClass=posixAccount)(mail=*@{{ domain }})(permission=cn=xmpp.main,ou=permission,dc=yunohost,dc=org))", filter = "(&(objectClass=posixAccount)(mail=*@{{ domain }})(permission=cn=xmpp.main,ou=permission,dc=yunohost,dc=org))",
usernamefield = "mail", usernamefield = "mail",
namefield = "cn", namefield = "cn",
}, },
} }
-- Discovery items -- Discovery items
disco_items = { disco_items = {
{ "muc.{{ domain }}" }, { "muc.{{ domain }}" },
{ "pubsub.{{ domain }}" }, { "pubsub.{{ domain }}" },
{ "jabber.{{ domain }}" }, { "jabber.{{ domain }}" },
{ "vjud.{{ domain }}" }, { "vjud.{{ domain }}" },
{ "xmpp-upload.{{ domain }}" }, { "xmpp-upload.{{ domain }}" },
}; };
-- contact_info = { -- contact_info = {
-- abuse = { "mailto:abuse@{{ domain }}", "xmpp:admin@{{ domain }}" }; -- abuse = { "mailto:abuse@{{ domain }}", "xmpp:admin@{{ domain }}" };
@ -35,41 +35,41 @@ VirtualHost "{{ domain }}"
---Set up a MUC (multi-user chat) room server ---Set up a MUC (multi-user chat) room server
Component "muc.{{ domain }}" "muc" Component "muc.{{ domain }}" "muc"
name = "{{ domain }} Chatrooms" name = "{{ domain }} Chatrooms"
modules_enabled = { modules_enabled = {
"muc_limits"; "muc_limits";
"muc_log"; "muc_log";
"muc_log_mam"; "muc_log_mam";
"muc_log_http"; "muc_log_http";
"muc_vcard"; "muc_vcard";
} }
muc_event_rate = 0.5 muc_event_rate = 0.5
muc_burst_factor = 10 muc_burst_factor = 10
room_default_config = { room_default_config = {
logging = true, logging = true,
persistent = true persistent = true
}; };
---Set up a PubSub server ---Set up a PubSub server
Component "pubsub.{{ domain }}" "pubsub" Component "pubsub.{{ domain }}" "pubsub"
name = "{{ domain }} Publish/Subscribe" name = "{{ domain }} Publish/Subscribe"
unrestricted_node_creation = true -- Anyone can create a PubSub node (from any server) unrestricted_node_creation = true -- Anyone can create a PubSub node (from any server)
---Set up a HTTP Upload service ---Set up a HTTP Upload service
Component "xmpp-upload.{{ domain }}" "http_upload" Component "xmpp-upload.{{ domain }}" "http_upload"
name = "{{ domain }} Sharing Service" name = "{{ domain }} Sharing Service"
http_file_path = "/var/xmpp-upload/{{ domain }}/upload" http_file_path = "/var/xmpp-upload/{{ domain }}/upload"
http_external_url = "https://xmpp-upload.{{ domain }}:443" http_external_url = "https://xmpp-upload.{{ domain }}:443"
http_file_base_path = "/upload" http_file_base_path = "/upload"
http_file_size_limit = 6*1024*1024 http_file_size_limit = 6*1024*1024
http_file_quota = 60*1024*1024 http_file_quota = 60*1024*1024
http_upload_file_size_limit = 100 * 1024 * 1024 -- bytes http_upload_file_size_limit = 100 * 1024 * 1024 -- bytes
http_upload_quota = 10 * 1024 * 1024 * 1024 -- bytes http_upload_quota = 10 * 1024 * 1024 * 1024 -- bytes
---Set up a VJUD service ---Set up a VJUD service
Component "vjud.{{ domain }}" "vjud" Component "vjud.{{ domain }}" "vjud"
vjud_disco_name = "{{ domain }} User Directory" vjud_disco_name = "{{ domain }} User Directory"

View file

@ -22,51 +22,51 @@
-- It looks for mod_modulename.lua in the plugins folder, so make sure that exists too. -- It looks for mod_modulename.lua in the plugins folder, so make sure that exists too.
modules_enabled = { modules_enabled = {
-- Generally required -- Generally required
"roster"; -- Allow users to have a roster. Recommended. "roster"; -- Allow users to have a roster. Recommended.
"saslauth"; -- Authentication for clients. Recommended if you want to log in. "saslauth"; -- Authentication for clients. Recommended if you want to log in.
"tls"; -- Add support for secure TLS on c2s/s2s connections "tls"; -- Add support for secure TLS on c2s/s2s connections
"disco"; -- Service discovery "disco"; -- Service discovery
-- Not essential, but recommended -- Not essential, but recommended
"private"; -- Private XML storage (for room bookmarks, etc.) "private"; -- Private XML storage (for room bookmarks, etc.)
"vcard"; -- Allow users to set vCards "vcard"; -- Allow users to set vCards
"pep"; -- Allows setting of mood, tune, etc. "pep"; -- Allows setting of mood, tune, etc.
"pubsub"; -- Publish-subscribe XEP-0060 "pubsub"; -- Publish-subscribe XEP-0060
"posix"; -- POSIX functionality, sends server to background, enables syslog, etc. "posix"; -- POSIX functionality, sends server to background, enables syslog, etc.
"bidi"; -- Enables Bidirectional Server-to-Server Streams. "bidi"; -- Enables Bidirectional Server-to-Server Streams.
-- Nice to have -- Nice to have
"version"; -- Replies to server version requests "version"; -- Replies to server version requests
"uptime"; -- Report how long server has been running "uptime"; -- Report how long server has been running
"time"; -- Let others know the time here on this server "time"; -- Let others know the time here on this server
"ping"; -- Replies to XMPP pings with pongs "ping"; -- Replies to XMPP pings with pongs
"register"; -- Allow users to register on this server using a client and change passwords "register"; -- Allow users to register on this server using a client and change passwords
"stream_management"; -- Allows clients and servers to use Stream Management "stream_management"; -- Allows clients and servers to use Stream Management
"stanza_optimizations"; -- Allows clients to use Client State Indication and SIFT "stanza_optimizations"; -- Allows clients to use Client State Indication and SIFT
"message_carbons"; -- Allows clients to enable carbon copies of messages "message_carbons"; -- Allows clients to enable carbon copies of messages
"mam"; -- Enable server-side message archives using Message Archive Management "mam"; -- Enable server-side message archives using Message Archive Management
"push"; -- Enable Push Notifications via PubSub using XEP-0357 "push"; -- Enable Push Notifications via PubSub using XEP-0357
"lastactivity"; -- Enables clients to know the last presence status of an user "lastactivity"; -- Enables clients to know the last presence status of an user
"adhoc_cm"; -- Allow to set client certificates to login through SASL External via adhoc "adhoc_cm"; -- Allow to set client certificates to login through SASL External via adhoc
"admin_adhoc"; -- administration adhoc commands "admin_adhoc"; -- administration adhoc commands
"bookmarks"; -- XEP-0048 Bookmarks synchronization between PEP and Private Storage "bookmarks"; -- XEP-0048 Bookmarks synchronization between PEP and Private Storage
"sec_labels"; -- Allows to use a simplified version XEP-0258 Security Labels and related ACDFs. "sec_labels"; -- Allows to use a simplified version XEP-0258 Security Labels and related ACDFs.
"privacy"; -- Add privacy lists and simple blocking command support "privacy"; -- Add privacy lists and simple blocking command support
-- Other specific functionality -- Other specific functionality
--"admin_telnet"; -- administration console, telnet to port 5582 --"admin_telnet"; -- administration console, telnet to port 5582
--"admin_web"; -- administration web interface --"admin_web"; -- administration web interface
"bosh"; -- Enable support for BOSH clients, aka "XMPP over Bidirectional Streams over Synchronous HTTP" "bosh"; -- Enable support for BOSH clients, aka "XMPP over Bidirectional Streams over Synchronous HTTP"
--"compression"; -- Allow clients to enable Stream Compression --"compression"; -- Allow clients to enable Stream Compression
--"spim_block"; -- Require authorization via OOB form for messages from non-contacts and block unsollicited messages --"spim_block"; -- Require authorization via OOB form for messages from non-contacts and block unsollicited messages
--"gate_guard"; -- Enable config-based blacklisting and hit-based auto-banning features --"gate_guard"; -- Enable config-based blacklisting and hit-based auto-banning features
--"incidents_handling"; -- Enable Incidents Handling support (can be administered via adhoc commands) --"incidents_handling"; -- Enable Incidents Handling support (can be administered via adhoc commands)
--"server_presence"; -- Enables Server Buddies extension support --"server_presence"; -- Enables Server Buddies extension support
--"service_directory"; -- Enables Service Directories extension support --"service_directory"; -- Enables Service Directories extension support
--"public_service"; -- Enables Server vCard support for public services in directories and advertises in features --"public_service"; -- Enables Server vCard support for public services in directories and advertises in features
--"register_api"; -- Provides secure API for both Out-Of-Band and In-Band registration for E-Mail verification --"register_api"; -- Provides secure API for both Out-Of-Band and In-Band registration for E-Mail verification
"websocket"; -- Enable support for WebSocket clients, aka "XMPP over WebSockets" "websocket"; -- Enable support for WebSocket clients, aka "XMPP over WebSockets"
}; };
-- Server PID -- Server PID
@ -102,10 +102,10 @@ csi_config_queue_all_muc_messages_but_mentions = false;
-- Logging configuration -- Logging configuration
log = { log = {
info = "/var/log/metronome/metronome.log"; -- Change 'info' to 'debug' for verbose logging info = "/var/log/metronome/metronome.log"; -- Change 'info' to 'debug' for verbose logging
error = "/var/log/metronome/metronome.err"; error = "/var/log/metronome/metronome.err";
-- "*syslog"; -- Uncomment this for logging to syslog -- "*syslog"; -- Uncomment this for logging to syslog
-- "*console"; -- Log to the console, useful for debugging with daemonize=false -- "*console"; -- Log to the console, useful for debugging with daemonize=false
} }
------ Components ------ ------ Components ------
@ -114,7 +114,7 @@ log = {
---Set up a local BOSH service ---Set up a local BOSH service
Component "localhost" "http" Component "localhost" "http"
modules_enabled = { "bosh" } modules_enabled = { "bosh" }
----------- Virtual hosts ----------- ----------- Virtual hosts -----------
-- You need to add a VirtualHost entry for each domain you wish Metronome to serve. -- You need to add a VirtualHost entry for each domain you wish Metronome to serve.

View file

@ -23,68 +23,68 @@ if not ldap then
end end
function new_default_provider(host) function new_default_provider(host)
local provider = { name = "ldap2" }; local provider = { name = "ldap2" };
log("debug", "initializing ldap2 authentication provider for host '%s'", host); log("debug", "initializing ldap2 authentication provider for host '%s'", host);
function provider.test_password(username, password) function provider.test_password(username, password)
return ldap.bind(username, password); return ldap.bind(username, password);
end end
function provider.user_exists(username) function provider.user_exists(username)
local params = ldap.getparams() local params = ldap.getparams()
local filter = ldap.filter.combine_and(params.user.filter, params.user.usernamefield .. '=' .. username); local filter = ldap.filter.combine_and(params.user.filter, params.user.usernamefield .. '=' .. username);
if params.user.usernamefield == 'mail' then if params.user.usernamefield == 'mail' then
filter = ldap.filter.combine_and(params.user.filter, 'mail=' .. username .. '@*'); filter = ldap.filter.combine_and(params.user.filter, 'mail=' .. username .. '@*');
end end
return ldap.singlematch { return ldap.singlematch {
base = params.user.basedn, base = params.user.basedn,
filter = filter, filter = filter,
}; };
end end
function provider.get_password(username) function provider.get_password(username)
return nil, "Passwords unavailable for LDAP."; return nil, "Passwords unavailable for LDAP.";
end end
function provider.set_password(username, password) function provider.set_password(username, password)
return nil, "Passwords unavailable for LDAP."; return nil, "Passwords unavailable for LDAP.";
end end
function provider.create_user(username, password) function provider.create_user(username, password)
return nil, "Account creation/modification not available with LDAP."; return nil, "Account creation/modification not available with LDAP.";
end end
function provider.get_sasl_handler(session) function provider.get_sasl_handler(session)
local testpass_authentication_profile = { local testpass_authentication_profile = {
session = session, session = session,
plain_test = function(sasl, username, password, realm) plain_test = function(sasl, username, password, realm)
return provider.test_password(username, password), true; return provider.test_password(username, password), true;
end, end,
order = { "plain_test" }, order = { "plain_test" },
}; };
return new_sasl(module.host, testpass_authentication_profile); return new_sasl(module.host, testpass_authentication_profile);
end end
function provider.is_admin(jid) function provider.is_admin(jid)
local admin_config = ldap.getparams().admin; local admin_config = ldap.getparams().admin;
if not admin_config then if not admin_config then
return; return;
end end
local ld = ldap:getconnection(); local ld = ldap:getconnection();
local username = jsplit(jid); local username = jsplit(jid);
local filter = ldap.filter.combine_and(admin_config.filter, admin_config.namefield .. '=' .. username); local filter = ldap.filter.combine_and(admin_config.filter, admin_config.namefield .. '=' .. username);
return ldap.singlematch { return ldap.singlematch {
base = admin_config.basedn, base = admin_config.basedn,
filter = filter, filter = filter,
}; };
end end
return provider; return provider;
end end
module:add_item("auth-provider", new_default_provider(module.host)); module:add_item("auth-provider", new_default_provider(module.host));

View file

@ -12,8 +12,8 @@ local st = require "util.stanza";
local t_concat = table.concat; local t_concat = table.concat;
local secure_auth_only = module:get_option("c2s_require_encryption") local secure_auth_only = module:get_option("c2s_require_encryption")
or module:get_option("require_encryption") or module:get_option("require_encryption")
or not(module:get_option("allow_unencrypted_plain_auth")); or not(module:get_option("allow_unencrypted_plain_auth"));
local sessionmanager = require "core.sessionmanager"; local sessionmanager = require "core.sessionmanager";
local usermanager = require "core.usermanager"; local usermanager = require "core.usermanager";
@ -22,66 +22,65 @@ local resourceprep = require "util.encodings".stringprep.resourceprep;
module:add_feature("jabber:iq:auth"); module:add_feature("jabber:iq:auth");
module:hook("stream-features", function(event) module:hook("stream-features", function(event)
local origin, features = event.origin, event.features; local origin, features = event.origin, event.features;
if secure_auth_only and not origin.secure then if secure_auth_only and not origin.secure then
-- Sorry, not offering to insecure streams! -- Sorry, not offering to insecure streams!
return; return;
elseif not origin.username then elseif not origin.username then
features:tag("auth", {xmlns='http://jabber.org/features/iq-auth'}):up(); features:tag("auth", {xmlns='http://jabber.org/features/iq-auth'}):up();
end end
end); end);
module:hook("stanza/iq/jabber:iq:auth:query", function(event) module:hook("stanza/iq/jabber:iq:auth:query", function(event)
local session, stanza = event.origin, event.stanza; local session, stanza = event.origin, event.stanza;
if session.type ~= "c2s_unauthed" then if session.type ~= "c2s_unauthed" then
(session.sends2s or session.send)(st.error_reply(stanza, "cancel", "service-unavailable", "Legacy authentication is only allowed for unauthenticated client connections.")); (session.sends2s or session.send)(st.error_reply(stanza, "cancel", "service-unavailable", "Legacy authentication is only allowed for unauthenticated client connections."));
return true; return true;
end end
if secure_auth_only and not session.secure then if secure_auth_only and not session.secure then
session.send(st.error_reply(stanza, "modify", "not-acceptable", "Encryption (SSL or TLS) is required to connect to this server")); session.send(st.error_reply(stanza, "modify", "not-acceptable", "Encryption (SSL or TLS) is required to connect to this server"));
return true; return true;
end end
local username = stanza.tags[1]:child_with_name("username"); local username = stanza.tags[1]:child_with_name("username");
local password = stanza.tags[1]:child_with_name("password"); local password = stanza.tags[1]:child_with_name("password");
local resource = stanza.tags[1]:child_with_name("resource"); local resource = stanza.tags[1]:child_with_name("resource");
if not (username and password and resource) then if not (username and password and resource) then
local reply = st.reply(stanza); local reply = st.reply(stanza);
session.send(reply:query("jabber:iq:auth") session.send(reply:query("jabber:iq:auth")
:tag("username"):up() :tag("username"):up()
:tag("password"):up() :tag("password"):up()
:tag("resource"):up()); :tag("resource"):up());
else else
username, password, resource = t_concat(username), t_concat(password), t_concat(resource); username, password, resource = t_concat(username), t_concat(password), t_concat(resource);
username = nodeprep(username); username = nodeprep(username);
resource = resourceprep(resource) resource = resourceprep(resource)
if not (username and resource) then if not (username and resource) then
session.send(st.error_reply(stanza, "modify", "bad-request")); session.send(st.error_reply(stanza, "modify", "bad-request"));
return true; return true;
end end
if usermanager.test_password(username, session.host, password) then if usermanager.test_password(username, session.host, password) then
-- Authentication successful! -- Authentication successful!
local success, err = sessionmanager.make_authenticated(session, username); local success, err = sessionmanager.make_authenticated(session, username);
if success then if success then
local err_type, err_msg; local err_type, err_msg;
success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource); success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource);
if not success then if not success then
session.send(st.error_reply(stanza, err_type, err, err_msg)); session.send(st.error_reply(stanza, err_type, err, err_msg));
session.username, session.type = nil, "c2s_unauthed"; -- FIXME should this be placed in sessionmanager? session.username, session.type = nil, "c2s_unauthed"; -- FIXME should this be placed in sessionmanager?
return true; return true;
elseif resource ~= session.resource then -- server changed resource, not supported by legacy auth elseif resource ~= session.resource then -- server changed resource, not supported by legacy auth
session.send(st.error_reply(stanza, "cancel", "conflict", "The requested resource could not be assigned to this session.")); session.send(st.error_reply(stanza, "cancel", "conflict", "The requested resource could not be assigned to this session."));
session:close(); -- FIXME undo resource bind and auth instead of closing the session? session:close(); -- FIXME undo resource bind and auth instead of closing the session?
return true; return true;
end end
end end
session.send(st.reply(stanza)); session.send(st.reply(stanza));
else else
session.send(st.error_reply(stanza, "auth", "not-authorized")); session.send(st.error_reply(stanza, "auth", "not-authorized"));
end end
end end
return true; return true;
end); end);

View file

@ -43,35 +43,35 @@ end
local get_alias_for_user; local get_alias_for_user;
do do
local user_cache; local user_cache;
local last_fetch_time; local last_fetch_time;
local function populate_user_cache() local function populate_user_cache()
local user_c = get_config(module.host, 'ldap').user; local user_c = get_config(module.host, 'ldap').user;
if not user_c then return; end if not user_c then return; end
local ld = ldap.getconnection(); local ld = ldap.getconnection();
local usernamefield = user_c.usernamefield; local usernamefield = user_c.usernamefield;
local namefield = user_c.namefield; local namefield = user_c.namefield;
user_cache = {}; user_cache = {};
for _, attrs in ld:search { base = user_c.basedn, scope = 'onelevel', filter = user_c.filter } do for _, attrs in ld:search { base = user_c.basedn, scope = 'onelevel', filter = user_c.filter } do
user_cache[attrs[usernamefield]] = attrs[namefield]; user_cache[attrs[usernamefield]] = attrs[namefield];
end end
last_fetch_time = gettime(); last_fetch_time = gettime();
end end
function get_alias_for_user(user) function get_alias_for_user(user)
if last_fetch_time and last_fetch_time + CACHE_EXPIRY < gettime() then if last_fetch_time and last_fetch_time + CACHE_EXPIRY < gettime() then
user_cache = nil; user_cache = nil;
end end
if not user_cache then if not user_cache then
populate_user_cache(); populate_user_cache();
end end
return user_cache[user]; return user_cache[user];
end end
end end
---------------------------------------- ----------------------------------------
@ -79,18 +79,18 @@ end
---------------------------------------- ----------------------------------------
local function ldap_store(config) local function ldap_store(config)
local self = {}; local self = {};
local config = config; local config = config;
function self:get(username) function self:get(username)
return nil, "Data getting is not available for this storage backend"; return nil, "Data getting is not available for this storage backend";
end end
function self:set(username, data) function self:set(username, data)
return nil, "Data setting is not available for this storage backend"; return nil, "Data setting is not available for this storage backend";
end end
return self; return self;
end end
local adapters = {}; local adapters = {};
@ -100,60 +100,60 @@ local adapters = {};
---------------------------------------- ----------------------------------------
adapters.roster = function (config) adapters.roster = function (config)
-- Validate configuration requirements -- Validate configuration requirements
if not config.groups then return nil; end if not config.groups then return nil; end
local self = ldap_store(config) local self = ldap_store(config)
function self:get(username) function self:get(username)
local ld = ldap.getconnection(); local ld = ldap.getconnection();
local contacts = {}; local contacts = {};
local memberfield = config.groups.memberfield; local memberfield = config.groups.memberfield;
local namefield = config.groups.namefield; local namefield = config.groups.namefield;
local filter = memberfield .. '=' .. tostring(username); local filter = memberfield .. '=' .. tostring(username);
local groups = {}; local groups = {};
for _, config in ipairs(config.groups) do for _, config in ipairs(config.groups) do
groups[ config[namefield] ] = config.name; groups[ config[namefield] ] = config.name;
end end
log("debug", "Found %d group(s) for user %s", select('#', groups), username) log("debug", "Found %d group(s) for user %s", select('#', groups), username)
-- XXX this kind of relies on the way we do groups at INOC -- XXX this kind of relies on the way we do groups at INOC
for _, attrs in ld:search { base = config.groups.basedn, scope = 'onelevel', filter = filter } do for _, attrs in ld:search { base = config.groups.basedn, scope = 'onelevel', filter = filter } do
if groups[ attrs[namefield] ] then if groups[ attrs[namefield] ] then
local members = attrs[memberfield]; local members = attrs[memberfield];
for _, user in ipairs(members) do for _, user in ipairs(members) do
if user ~= username then if user ~= username then
local jid = user .. '@' .. module.host; local jid = user .. '@' .. module.host;
local record = contacts[jid]; local record = contacts[jid];
if not record then if not record then
record = { record = {
subscription = 'both', subscription = 'both',
groups = {}, groups = {},
name = get_alias_for_user(user), name = get_alias_for_user(user),
}; };
contacts[jid] = record; contacts[jid] = record;
end end
record.groups[ groups[ attrs[namefield] ] ] = true; record.groups[ groups[ attrs[namefield] ] ] = true;
end end
end end
end end
end end
return contacts; return contacts;
end end
function self:set(username, data) function self:set(username, data)
log("warn", "Setting data in Roster LDAP storage is not supported yet") log("warn", "Setting data in Roster LDAP storage is not supported yet")
return nil, "not supported"; return nil, "not supported";
end end
return self; return self;
end end
---------------------------------------- ----------------------------------------
@ -161,35 +161,35 @@ end
---------------------------------------- ----------------------------------------
adapters.vcard = function (config) adapters.vcard = function (config)
-- Validate configuration requirements -- Validate configuration requirements
if not config.vcard_format or not config.user then return nil; end if not config.vcard_format or not config.user then return nil; end
local self = ldap_store(config) local self = ldap_store(config)
function self:get(username) function self:get(username)
local ld = ldap.getconnection(); local ld = ldap.getconnection();
local filter = config.user.usernamefield .. '=' .. tostring(username); local filter = config.user.usernamefield .. '=' .. tostring(username);
log("debug", "Retrieving vCard for user '%s'", username); log("debug", "Retrieving vCard for user '%s'", username);
local match = ldap.singlematch { local match = ldap.singlematch {
base = config.user.basedn, base = config.user.basedn,
filter = filter, filter = filter,
}; };
if match then if match then
match.jid = username .. '@' .. module.host match.jid = username .. '@' .. module.host
return st.preserialize(ldap_record_to_vcard(match, config.vcard_format)); return st.preserialize(ldap_record_to_vcard(match, config.vcard_format));
else else
return nil, "username not found"; return nil, "username not found";
end end
end end
function self:set(username, data) function self:set(username, data)
log("warn", "Setting data in vCard LDAP storage is not supported yet") log("warn", "Setting data in vCard LDAP storage is not supported yet")
return nil, "not supported"; return nil, "not supported";
end end
return self; return self;
end end
---------------------------------------- ----------------------------------------

View file

@ -135,28 +135,28 @@ function builder_methods:build()
end end
local function new_builder(params) local function new_builder(params)
local vcard_tag = st.stanza('vCard', { xmlns = VCARD_NS }); local vcard_tag = st.stanza('vCard', { xmlns = VCARD_NS });
local object = { local object = {
vcard = vcard_tag, vcard = vcard_tag,
__index = builder_methods, __index = builder_methods,
}; };
for k, v in pairs(params) do for k, v in pairs(params) do
object[k] = v; object[k] = v;
end end
setmetatable(object, object); setmetatable(object, object);
return object; return object;
end end
local _M = {}; local _M = {};
function _M.create(params) function _M.create(params)
local builder = new_builder(params); local builder = new_builder(params);
return builder:build(); return builder:build();
end end
return _M; return _M;