Enforce minimum maubot version in plugin meta
This commit is contained in:
parent
29b4a3c892
commit
4b234e4d34
1 changed files with 6 additions and 0 deletions
|
@ -26,12 +26,14 @@ from ruamel.yaml import YAML, YAMLError
|
||||||
|
|
||||||
from mautrix.types import SerializerError
|
from mautrix.types import SerializerError
|
||||||
|
|
||||||
|
from ..__meta__ import __version__
|
||||||
from ..config import Config
|
from ..config import Config
|
||||||
from ..lib.zipimport import ZipImportError, zipimporter
|
from ..lib.zipimport import ZipImportError, zipimporter
|
||||||
from ..plugin_base import Plugin
|
from ..plugin_base import Plugin
|
||||||
from .abc import IDConflictError, PluginClass, PluginLoader
|
from .abc import IDConflictError, PluginClass, PluginLoader
|
||||||
from .meta import PluginMeta
|
from .meta import PluginMeta
|
||||||
|
|
||||||
|
current_version = Version(__version__)
|
||||||
yaml = YAML()
|
yaml = YAML()
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,6 +148,10 @@ class ZippedPluginLoader(PluginLoader):
|
||||||
meta = PluginMeta.deserialize(meta_dict)
|
meta = PluginMeta.deserialize(meta_dict)
|
||||||
except SerializerError as e:
|
except SerializerError as e:
|
||||||
raise MaubotZipMetaError("Maubot plugin definition in file is invalid") from e
|
raise MaubotZipMetaError("Maubot plugin definition in file is invalid") from e
|
||||||
|
if meta.maubot > current_version:
|
||||||
|
raise MaubotZipMetaError(
|
||||||
|
f"Plugin requires maubot {meta.maubot}, but this instance is {current_version}"
|
||||||
|
)
|
||||||
return file, meta
|
return file, meta
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in a new issue