TT#66583 changes needed for support 0.11

* sipwise_groups:
  changes in arguments of roster-load event
* sipwise_lastactivity:
  integrate improvements from prosody 0.11
* sipwise_vhosts_sql:
  enable muc_mam if mam is enabled

Add README.md with some manual checks I do to test the
functionality in profanity

Change-Id: Ia3df562b35dbe37e4d8da7661a7a7634d2c61768
changes/04/35004/5
Victor Seva 6 years ago
parent f9b0c6f6d6
commit 157f5fe6d7

@ -0,0 +1,128 @@
examples of messages for testing funtionality
---------------------------------------------
* mod_sipwise_lastactivity:
```
<iq id='last1' to='43991002@192.168.1.102' type='get'>
<query xmlns='jabber:iq:last'/>
</iq>
```
```
<iq id="last1" to="43991002@192.168.1.102/profanity" type="result">
<query xmlns="jabber:iq:last" seconds="8"/>
</iq>
```
* mod_sipwise_vcard_cusax:
```
<iq id='bx81v356' to='43991002@192.168.1.102' type='get'>
<vCard xmlns='vcard-temp'/>
</iq>
```
response:
```
<iq id="bx81v356" to="43991002@192.168.1.102/profanity" type="result">
<vCard prodid="-//HandGen//NONSGML vGen v1.0//EN" xmlns="vcard-temp" version="2.0">
<JABBERID>43991002@192.168.1.102</JABBERID>
<TEL><VIDEO/><NUMBER>sip:43991002@192.168.1.102</NUMBER></TEL>
<TEL><VOICE/><NUMBER>43991002</NUMBER></TEL>
<EMAIL><INTERNET/><PREF/><USERID>default-customer@default.invalid</USERID></EMAIL>
</vCard>
</iq>
```
* mod_sipwise_vhosts_sql:
```
<iq id="discoitemsreq" to="192.168.1.102" type="get">
<query xmlns="http://jabber.org/protocol/disco#items"/>
</iq>
```
response:
```
<iq id="discoitemsreq" to="43991002@192.168.1.102/profanity" type="result" from="192.168.1.102">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="search.192.168.1.102"/>
<item jid="conference.192.168.1.102"/>
</query>
</iq>
```
* mod_sipwise_vjud:
discover search fields
```
<iq type='get' to='search.192.168.1.102' id='search1' xml:lang='en'>
<query xmlns='jabber:iq:search'/>
</iq>
```
response:
```
<iq id="search1" to="43991002@192.168.1.102/profanity" type="result" from="search.192.168.1.102">
<query xmlns="jabber:iq:search">
<instructions>Use the enclosed form to search</instructions>
<x xmlns="jabber:x:data" type="form">
<title>User Directory Search</title>
<instructions>Please provide the following information to search for subscribers</instructions>
<field type="hidden" var="FORM_TYPE"><value>jabber:iq:search</value></field>
<field label="e164 Phone number" type="text-single" var="e164"/>
<field label="domain" type="text-single" var="domain"/>
</x>
<nick/>
</query>
</iq>
```
search domain:
```
<iq type='set' to='search.192.168.1.102' id='search2' xml:lang='en'><query xmlns='jabber:iq:search'>
<x xmlns='jabber:x:data' type='submit'>
<field type='hidden' var='FORM_TYPE'>
<value>jabber:iq:search</value>
</field>
<field var='domain'>
<value>192.168.1.102</value>
</field>
</x>
</query>
</iq>
```
response:
```
<iq id="search2" to="43991002@192.168.1.102/profanity" type="result" from="search.192.168.1.102">
<query xmlns="jabber:iq:search">
<x xmlns="jabber:x:data" type="result">
<field type="hidden" var="FORM_TYPE"><value>jabber:iq:search</value></field>
<reported><field label="domain" type="text-single" var="domain"/></reported>
<item><field var="domain"><value>192.168.1.102</value></field></item>
</x>
</query>
</iq>
```
search number:
```
<iq type='set' to='search.192.168.1.102' id='search3' xml:lang='en'><query xmlns='jabber:iq:search'>
<x xmlns='jabber:x:data' type='submit'>
<field type='hidden' var='FORM_TYPE'>
<value>jabber:iq:search</value>
</field>
<field var='e164'>
<value>43991003</value>
</field>
</x>
</query>
</iq>
```
response:
```
<iq id="search3" type="result" to="43991002@192.168.1.102/profanity" from="search.192.168.1.102">
<query xmlns="jabber:iq:search">
<x xmlns="jabber:x:data" type="result">
<field type="hidden" var="FORM_TYPE"><value>jabber:iq:search</value></field>
<reported><field label="e164 Phone number" type="text-single" var="e164"/></reported>
<item><field var="e164"><value>43991003@192.168.1.102</value></field></item>
</x>
</query>
</iq>
```

@ -141,7 +141,8 @@ local displayname_preference_id;
-- "roster-load" callback
local function inject_roster_contacts(username, host, roster)
local function inject_roster_contacts(event)
local username, host, roster = event.username, event.host, event.roster;
module:log("debug", "Injecting group members to roster");
local bare_jid = username.."@"..host;
local account_id, groups, display_names;

@ -23,14 +23,29 @@ module:hook("pre-presence/bare", function(event)
local stanza = event.stanza;
if not(stanza.attr.to) then
local t = os.time();
local s = stanza:child_with_name("status");
s = s and #s.tags == 0 and s[1] or "";
local s = stanza:get_child_text("status");
map[event.origin.username] = {s = s, t = t};
module:log("debug", string.format("change of presence:%s from:%s",
tostring(s), tostring(event.origin.username)));
end
end, 10);
module:hook("iq-get/bare/jabber:iq:last:query", function(event)
local origin, stanza = event.origin, event.stanza;
local username = jid_split(stanza.attr.to) or origin.username;
if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then
local seconds, text = nil, "";
if not sessions[origin.conn] and map[username] then
seconds = tostring(os.difftime(os.time(), map[username].t));
text = map[username].s;
end
origin.send(st.reply(stanza):tag('query', {xmlns='jabber:iq:last', seconds=seconds}):text(text));
else
origin.send(st.error_reply(stanza, 'auth', 'forbidden'));
end
return true;
end);
local function msg_handler(event)
local origin, stanza = event.origin, event.stanza;
local username = jid_split(stanza.attr.from) or origin.username;
@ -42,21 +57,3 @@ end
-- lastactivity: any message sent
module:hook("pre-message/bare", msg_handler);
module:hook("pre-message/full", msg_handler);
module:hook("iq/bare/jabber:iq:last:query", function(event)
local origin, stanza = event.origin, event.stanza;
if stanza.attr.type == "get" then
local username = jid_split(stanza.attr.to) or origin.username;
if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then
local seconds, text = nil, "";
if not sessions[origin.conn] and map[username] then
seconds = tostring(os.difftime(os.time(), map[username].t));
text = map[username].s;
end
origin.send(st.reply(stanza):tag('query', {xmlns='jabber:iq:last', seconds=seconds}):text(text));
else
origin.send(st.error_reply(stanza, 'auth', 'forbidden'));
end
return true;
end
end);

@ -115,6 +115,9 @@ local function load_vhosts_from_db()
if ut.table.contains(host_modules, "sipwise_pushd") then
ut.table.add(conference_modules, "sipwise_pushd");
end
if ut.table.contains(host_modules, "mam") then
ut.table.add(conference_modules, "muc_mam");
end
module:log("debug", "conference_modules[%s]: %s",
"conference."..row.domain, ut.table.tostring(host_modules));
configmanager.set("conference."..row.domain, "modules_enabled",

Loading…
Cancel
Save