Refactor custom_plugin method to accept arguments/body from request

This commit is contained in:
Théophile Diot 2024-01-31 13:57:39 +01:00
parent bc65918fa9
commit ad1625a867
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -1299,7 +1299,12 @@ def custom_plugin(plugin):
try:
# Try to get the custom plugin custom function and call it
method = getattr(actions, plugin)
res = method()
if request.args:
res = method(**request.args.to_dict())
elif request.json:
res = method(**request.json)
else:
res = method()
except AttributeError:
message = f'The plugin "{plugin}" does not have a "{plugin}" method'
error = 404