Workaround for prosody PEP support in group chat with OMEMO
This commit is contained in:
parent
ed9fb5bc4a
commit
46f5c877b5
|
@ -0,0 +1,55 @@
|
|||
-- OMEMO all access module
|
||||
-- Copyright (c) 2017 Daniel Gultsch
|
||||
--
|
||||
-- This module is MIT/X11 licensed
|
||||
--
|
||||
|
||||
local jid_bare = require "util.jid".bare;
|
||||
local st = require "util.stanza"
|
||||
local white_listed_namespace = "eu.siacs.conversations.axolotl."
|
||||
local disco_feature_namespace = white_listed_namespace .. "whitelisted"
|
||||
|
||||
local mod_pep = module:depends"pep";
|
||||
local pep_data = mod_pep.module.save().data;
|
||||
|
||||
local function on_account_disco_info(event)
|
||||
(event.reply or event.stanza):tag("feature", {var=disco_feature_namespace}):up();
|
||||
end
|
||||
|
||||
local function on_pep_request(event)
|
||||
local session, stanza = event.origin, event.stanza
|
||||
local payload = stanza.tags[1];
|
||||
if stanza.attr.type == 'get' then
|
||||
local node, requested_id;
|
||||
payload = payload.tags[1]
|
||||
if payload and payload.name == 'items' then
|
||||
node = payload.attr.node
|
||||
local item = payload.tags[1];
|
||||
if item and item.name == 'item' then
|
||||
requested_id = item.attr.id;
|
||||
end
|
||||
end
|
||||
if node and string.sub(node,1,string.len(white_listed_namespace)) == white_listed_namespace then
|
||||
local user = stanza.attr.to and jid_bare(stanza.attr.to) or session.username..'@'..session.host;
|
||||
local user_data = pep_data[user];
|
||||
if user_data and user_data[node] then
|
||||
local id, item = unpack(user_data[node]);
|
||||
if not requested_id or id == requested_id then
|
||||
local stanza = st.reply(stanza)
|
||||
:tag('pubsub', {xmlns='http://jabber.org/protocol/pubsub'})
|
||||
:tag('items', {node=node})
|
||||
:add_child(item)
|
||||
:up()
|
||||
:up();
|
||||
session.send(stanza);
|
||||
module:log("debug","provided access to omemo node",node)
|
||||
return true;
|
||||
end
|
||||
end
|
||||
module:log("debug","requested node was white listed", node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module:hook("iq/bare/http://jabber.org/protocol/pubsub:pubsub", on_pep_request, 10);
|
||||
module:hook("account-disco-info", on_account_disco_info);
|
|
@ -326,6 +326,43 @@ function update_prosody_modules {
|
|||
return
|
||||
fi
|
||||
|
||||
# This module is a workaround for OMEMO within group chat
|
||||
# See https://github.com/iNPUTmice/omemo_all_access
|
||||
if [ -f ~/freedombone/image_build/mod_omemo_all_access.lua ]; then
|
||||
if [ ! -d /var/lib/prosody/prosody-modules ]; then
|
||||
mkdir -p /var/lib/prosody/prosody-modules
|
||||
fi
|
||||
|
||||
copy_omemo_all_access=1
|
||||
if [ -f /usr/lib/prosody/modules/mod_omemo_all_access.lua ]; then
|
||||
curr_hash=$(sha256sum /usr/lib/prosody/modules/mod_omemo_all_access.lua)
|
||||
new_hash=$(sha256sum ~/freedombone/image_build/mod_omemo_all_access.lua)
|
||||
if [[ "$curr_hash" == "$new_hash" ]]; then
|
||||
copy_omemo_all_access=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $copy_omemo_all_access ]; then
|
||||
systemctl stop prosody
|
||||
cp ~/freedombone/image_build/mod_omemo_all_access.lua /var/lib/prosody/prosody-modules/mod_omemo_all_access.lua
|
||||
cp ~/freedombone/image_build/mod_omemo_all_access.lua /usr/lib/prosody/modules/mod_omemo_all_access.lua
|
||||
|
||||
if ! grep -q "omemo_all_access" /etc/prosody/prosody.cfg.lua; then
|
||||
sed -i '/"pep";/a "omemo_all_access"; -- Fix for PEP with OMEMO' /etc/prosody/prosody.cfg.lua
|
||||
sed -i 's|"omemo_all_access";| "omemo_all_access";|g' /etc/prosody/prosody.cfg.lua
|
||||
fi
|
||||
|
||||
if ! grep -q "omemo_all_access" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
||||
sed -i '/"pep";/a "omemo_all_access"; -- Fix for PEP with OMEMO' /etc/prosody/conf.avail/xmpp.cfg.lua
|
||||
sed -i 's|"omemo_all_access";| "omemo_all_access";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
||||
fi
|
||||
|
||||
chown -R prosody:prosody /var/lib/prosody/prosody-modules
|
||||
chown -R prosody:prosody /usr/lib/prosody/modules
|
||||
systemctl start prosody
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f $INSTALL_DIR/$prosody_modules_filename ]; then
|
||||
# Obtain the modules
|
||||
if [ -f ~/freedombone/image_build/$prosody_modules_filename ]; then
|
||||
|
@ -624,6 +661,7 @@ function xmpp_modules {
|
|||
echo ' "smacks"; -- Stream management' >> $filename
|
||||
echo ' "smacks_offline"; -- Stream management' >> $filename
|
||||
echo ' "pep"; -- Personal Eventing Protocol (to support OMEMO)' >> $filename
|
||||
echo ' "omemo_all_access"; -- Fix for PEP with OMEMO' >> $filename
|
||||
echo ' "vcard"; -- Personal Eventing Protocol (to support OMEMO)' >> $filename
|
||||
echo ' "e2e_policy"; -- To support OMEMO' >> $filename
|
||||
echo ' "pep_vcard_avatar"; -- Personal Eventing Protocol (to support OMEMO)' >> $filename
|
||||
|
|
Loading…
Reference in New Issue