Merge pull request #1645 from symonbaikov/feature/apprise-config-options
feat: add operator config options for Apprise notifications (closes #1576)
This commit is contained in:
@@ -23,11 +23,28 @@ module.exports = {
|
||||
},
|
||||
|
||||
exits: {
|
||||
appriseDisabled: {},
|
||||
schemaNotAllowed: {},
|
||||
limitReached: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
const { appriseEnabled, appriseAllowedSchemas, appriseBlockedSchemas } = sails.config.custom;
|
||||
|
||||
if (!appriseEnabled) {
|
||||
throw 'appriseDisabled';
|
||||
}
|
||||
|
||||
const schema = values.url.split(':')[0];
|
||||
|
||||
if (appriseAllowedSchemas.length > 0 && !appriseAllowedSchemas.includes(schema)) {
|
||||
throw 'schemaNotAllowed';
|
||||
}
|
||||
|
||||
if (appriseAllowedSchemas.length === 0 && appriseBlockedSchemas.includes(schema)) {
|
||||
throw 'schemaNotAllowed';
|
||||
}
|
||||
|
||||
const notificationServicesTotal = await sails.helpers.boards.getNotificationServicesTotal(
|
||||
values.board.id,
|
||||
|
||||
@@ -19,11 +19,28 @@ module.exports = {
|
||||
},
|
||||
|
||||
exits: {
|
||||
appriseDisabled: {},
|
||||
schemaNotAllowed: {},
|
||||
limitReached: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
const { appriseEnabled, appriseAllowedSchemas, appriseBlockedSchemas } = sails.config.custom;
|
||||
|
||||
if (!appriseEnabled) {
|
||||
throw 'appriseDisabled';
|
||||
}
|
||||
|
||||
const schema = values.url.split(':')[0];
|
||||
|
||||
if (appriseAllowedSchemas.length > 0 && !appriseAllowedSchemas.includes(schema)) {
|
||||
throw 'schemaNotAllowed';
|
||||
}
|
||||
|
||||
if (appriseAllowedSchemas.length === 0 && appriseBlockedSchemas.includes(schema)) {
|
||||
throw 'schemaNotAllowed';
|
||||
}
|
||||
|
||||
const notificationServicesTotal = await sails.helpers.users.getNotificationServicesTotal(
|
||||
values.user.id,
|
||||
|
||||
@@ -31,6 +31,17 @@ module.exports = {
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { appriseEnabled, appriseAllowedSchemas, appriseBlockedSchemas } = sails.config.custom;
|
||||
|
||||
if (!appriseEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const schemaConfig = JSON.stringify({
|
||||
allowedSchemas: appriseAllowedSchemas,
|
||||
blockedSchemas: appriseBlockedSchemas,
|
||||
});
|
||||
|
||||
try {
|
||||
await promisifyExecFile(
|
||||
PYTHON_PATH,
|
||||
@@ -39,6 +50,7 @@ module.exports = {
|
||||
JSON.stringify(inputs.services),
|
||||
inputs.title,
|
||||
JSON.stringify(inputs.bodyByFormat),
|
||||
schemaConfig,
|
||||
],
|
||||
{
|
||||
env: {
|
||||
|
||||
Reference in New Issue
Block a user