I may be overthinking this and / or missing the obvious, but I have found no way to trigger a notification add without it coming explicitly from a machine using the defined pattern:
//action:notification your message goes here
Looking over the plugin itself, I saw no way other than the action hook (assumedly wired directly into the serial comm interface) to add a notification.
You can delete them and list them via the API, but there's no add.
Is this by design? If not, I've got a pull request I may want to submit with the following changes to it:
def get_additional_permissions(self):
return [
...
{
"key": "ADD",
"name": "Add printer notifications",
"description": gettext("Allows to add printer notifications"),
"default_groups": [USER_GROUP],
"roles": ["add"],
},
]
def get_api_commands(self):
return {"clear": [], "add": []}
def on_api_command(self, command, data):
...
if command == "add":
if not Permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_ADD.can():
return flask.abort(403, "Insufficient permissions")
self._add_notification(data.get("message"))
def _add_notification(self, message):
self._notifications.append((time.time(), message))
self._plugin_manager.send_plugin_message(self._identifier, {"message": message})
self._logger.info("Got a notification: {}".format(message))
I also modified action_command_handler
to use _add_notification
rather than duplicate code.