Changeset

3222:c22b6283d226

mod_pep_vcard_png_avatar: Log error when used with new mod_pep, add compat with mod_pep_simple
author Matthew Wild <mwild1@gmail.com>
date Thu, 09 Aug 2018 22:40:18 +0100
parents 3221:b98c7c33550e
children 3223:9a89ec5030b5
files mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua	Thu Aug 09 22:36:22 2018 +0100
+++ b/mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua	Thu Aug 09 22:40:18 2018 +0100
@@ -12,9 +12,27 @@
 local base64 = require"util.encodings".base64;
 local sha1 = require"util.hashes".sha1;
 
-local mod_pep = module:depends"pep";
+local mm = require "core.modulemanager";
+
+-- COMPAT w/trunk
+local pep_module_name = "pep";
+if mm.get_modules_for_host then
+	if mm.get_modules_for_host(module.host):contains("pep_simple") then
+		pep_module_name = "pep_simple";
+	end
+end
+
+local mod_pep = module:depends(pep_module_name);
 local pep_data = mod_pep.module.save().data;
 
+if not pep_data then
+	module:log("error", "This module is not compatible with your version of mod_pep");
+	if mm.get_modules_for_host then
+		module:log("error", "Please use mod_pep_simple instead of mod_pep to continue using this module");
+	end
+	return false;
+end
+
 module:add_feature("http://prosody.im/protocol/vcard-pep-integration");
 module:depends"vcard";
 local vcard_storage = module:open_store("vcard");