xep_0384: rework passing in storage class

The previous way wasn't allowing passing classes with different
parameters.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2019-01-31 11:21:54 +01:00
parent 33d605f5e2
commit 6641404def

View file

@ -130,7 +130,7 @@ class XEP_0384(BasePlugin):
dependencies = {'xep_0163'} dependencies = {'xep_0163'}
default_config = { default_config = {
'data_dir': None, 'data_dir': None,
'storage_backend': JSONFileStorage, 'storage_backend': None,
'otpk_policy': DefaultOTPKPolicy, 'otpk_policy': DefaultOTPKPolicy,
'omemo_backend': SignalBackend, 'omemo_backend': SignalBackend,
} }
@ -148,7 +148,10 @@ class XEP_0384(BasePlugin):
"specified") "specified")
return None return None
storage = self.storage_backend(self.data_dir) storage = self.storage_backend
if self.storage_backend is None:
storage = JSONFileStorage(self.data_dir)
otpkpolicy = self.otpk_policy() otpkpolicy = self.otpk_policy()
bare_jid = self.xmpp.boundjid.bare bare_jid = self.xmpp.boundjid.bare
self._device_id = _load_device_id(self.data_dir) self._device_id = _load_device_id(self.data_dir)