[ { "id": "51a528cb51e0702f", "type": "tab", "label": "Blacklist", "disabled": false, "info": "", "env": [] }, { "id": "cc37ae5bc523b60f", "type": "http response", "z": "51a528cb51e0702f", "name": "200 ok", "statusCode": "200", "headers": {}, "x": 1090, "y": 100, "wires": [] }, { "id": "ca3e1b4d3ec96069", "type": "http response", "z": "51a528cb51e0702f", "name": "404 nok", "statusCode": "404", "headers": {}, "x": 1100, "y": 140, "wires": [] }, { "id": "0b3b767e0de86da2", "type": "function", "z": "51a528cb51e0702f", "name": "function 1", "func": "const callerid = msg.req.headers.x_callerid;\nnode.warn("callerid=" + callerid);\nconst exten = msg.req.headers.exten;\nvar dataDB = msg.dataDB;\nvar blacklist = false;\n\nnode.warn("dataDB= " + dataDB);\n\nfor(let i = 0; i < dataDB.length; i++) {\n var numero = dataDB[i].NUMERO;\n\n\n if (callerid == numero) {\n blacklist = true;\n }\n else {\n blacklist = false;\n }\n\n\n}\n\nif (blacklist == true) {\n blacklist = false;\n return [null, msg]\n}\nelse{\n blacklist = false;\n return [msg, null];\n}\n\n", "outputs": 2, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 920, "y": 120, "wires": [ [ "cc37ae5bc523b60f" ], [ "ca3e1b4d3ec96069" ] ] }, { "id": "4463571630fa4d06", "type": "http in", "z": "51a528cb51e0702f", "name": "blacklist", "url": "/blacklist", "method": "get", "upload": false, "swaggerDoc": "", "x": 130, "y": 120, "wires": [ [ "7533b6aeec0ba4f4" ] ] }, { "id": "7533b6aeec0ba4f4", "type": "change", "z": "51a528cb51e0702f", "name": "msg.req.headers", "rules": [ { "t": "move", "p": "req.headers.x-callerid", "pt": "msg", "to": "req.headers.x_callerid", "tot": "msg" }, { "t": "set", "p": "topic", "pt": "msg", "to": "SELECT * FROM BLACKLIST", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 310, "y": 120, "wires": [ [ "269f84d3be6c482c" ] ] }, { "id": "269f84d3be6c482c", "type": "sqlite", "z": "51a528cb51e0702f", "mydb": "bb9bc60aa241cba7", "sqlquery": "msg.topic", "sql": "", "name": "blacklist", "x": 500, "y": 120, "wires": [ [ "d8f5e42e73496565" ] ] }, { "id": "d8f5e42e73496565", "type": "change", "z": "51a528cb51e0702f", "name": "msg.req.headers", "rules": [ { "t": "move", "p": "payload", "pt": "msg", "to": "dataDB", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 690, "y": 120, "wires": [ [ "0b3b767e0de86da2" ] ] }, { "id": "bb9bc60aa241cba7", "type": "sqlitedb", "db": "/data/noderedtest/blacklist.db", "mode": "RWC" } ]
No due date set.
This issue currently doesn't have any dependencies.
Deleting a branch is permanent. It CANNOT be undone. Continue?
[
{
"id": "51a528cb51e0702f",
"type": "tab",
"label": "Blacklist",
"disabled": false,
"info": "",
"env": []
},
{
"id": "cc37ae5bc523b60f",
"type": "http response",
"z": "51a528cb51e0702f",
"name": "200 ok",
"statusCode": "200",
"headers": {},
"x": 1090,
"y": 100,
"wires": []
},
{
"id": "ca3e1b4d3ec96069",
"type": "http response",
"z": "51a528cb51e0702f",
"name": "404 nok",
"statusCode": "404",
"headers": {},
"x": 1100,
"y": 140,
"wires": []
},
{
"id": "0b3b767e0de86da2",
"type": "function",
"z": "51a528cb51e0702f",
"name": "function 1",
"func": "const callerid = msg.req.headers.x_callerid;\nnode.warn("callerid=" + callerid);\nconst exten = msg.req.headers.exten;\nvar dataDB = msg.dataDB;\nvar blacklist = false;\n\nnode.warn("dataDB= " + dataDB);\n\nfor(let i = 0; i < dataDB.length; i++) {\n var numero = dataDB[i].NUMERO;\n\n\n if (callerid == numero) {\n blacklist = true;\n }\n else {\n blacklist = false;\n }\n\n\n}\n\nif (blacklist == true) {\n blacklist = false;\n return [null, msg]\n}\nelse{\n blacklist = false;\n return [msg, null];\n}\n\n",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 920,
"y": 120,
"wires": [
[
"cc37ae5bc523b60f"
],
[
"ca3e1b4d3ec96069"
]
]
},
{
"id": "4463571630fa4d06",
"type": "http in",
"z": "51a528cb51e0702f",
"name": "blacklist",
"url": "/blacklist",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 130,
"y": 120,
"wires": [
[
"7533b6aeec0ba4f4"
]
]
},
{
"id": "7533b6aeec0ba4f4",
"type": "change",
"z": "51a528cb51e0702f",
"name": "msg.req.headers",
"rules": [
{
"t": "move",
"p": "req.headers.x-callerid",
"pt": "msg",
"to": "req.headers.x_callerid",
"tot": "msg"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "SELECT * FROM BLACKLIST",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 310,
"y": 120,
"wires": [
[
"269f84d3be6c482c"
]
]
},
{
"id": "269f84d3be6c482c",
"type": "sqlite",
"z": "51a528cb51e0702f",
"mydb": "bb9bc60aa241cba7",
"sqlquery": "msg.topic",
"sql": "",
"name": "blacklist",
"x": 500,
"y": 120,
"wires": [
[
"d8f5e42e73496565"
]
]
},
{
"id": "d8f5e42e73496565",
"type": "change",
"z": "51a528cb51e0702f",
"name": "msg.req.headers",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "dataDB",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 690,
"y": 120,
"wires": [
[
"0b3b767e0de86da2"
]
]
},
{
"id": "bb9bc60aa241cba7",
"type": "sqlitedb",
"db": "/data/noderedtest/blacklist.db",
"mode": "RWC"
}
]
Ajouter codeto Json Node-Red blacklist 2 years ago