enable all js extensions

This commit is contained in:
Martin Rotter 2021-03-21 18:40:30 +01:00 committed by Martin Rotter
parent 6fcb96f36c
commit 279256c27d
2 changed files with 3 additions and 2 deletions

View File

@ -73,7 +73,7 @@ Here is the reference of methods and properties of some types available in your
|---|---|---|
| `Accept` | 1 | Message is accepted and will be added to DB or updated in DB. |
| `Ignore` | 2 | Message is ignored and will be **NOT** added to DB or updated in DB, but is not purged from DB if already exists. |
| `Purge` | 4 | Existing message is purged from the DB completely. |
| `Purge` | 4 | Existing message is purged from the DB completely. Behavior is the same as `Ignore` when there is new incoming message. |
Note that `MessageObject` attributes which can be synchronized back to service are synchronized even if you return `Purge` or `Ignore`. In other words: even if you filter ignores the message you can still tweak its properties which will get synchronized back to your server.

View File

@ -52,9 +52,10 @@ void MessageFilter::setScript(const QString& script) {
}
void MessageFilter::initializeFilteringEngine(QJSEngine& engine, MessageObject* message_wrapper) {
engine.installExtensions(QJSEngine::Extension::ConsoleExtension);
engine.installExtensions(QJSEngine::Extension::AllExtensions);
engine.globalObject().setProperty(QSL("MSG_ACCEPT"), int(MessageObject::FilteringAction::Accept));
engine.globalObject().setProperty(QSL("MSG_IGNORE"), int(MessageObject::FilteringAction::Ignore));
engine.globalObject().setProperty(QSL("MSG_PURGE"), int(MessageObject::FilteringAction::Purge));
// Register the wrapper.
auto js_object = engine.newQObject(message_wrapper);