fix: repeated result when resubmit

This commit is contained in:
Renge 2024-04-17 18:40:52 -04:00
parent e6d0ece5bb
commit 9ffb9e334c

View File

@ -4,10 +4,6 @@ const swipl = require('swipl');
const app = express()
const PORT = 3000
swipl.call('assert(ip("_", "_"))');
swipl.call('assert(nip("_", "_"))');
swipl.call('assert(all("_", "_"))');
swipl.call('assert((allowed_to_send_email(Domain, IP) :- (ip(Domain, IP)), once(\\+ all(Domain, "-"); \\+ nip(Domain, IP))))');
const spf = (req, res) => {
try {
@ -40,6 +36,10 @@ const spf = (req, res) => {
console.error(err)
return res.status(err.code).send(err.message)
}
swipl.call('assert(ip("_", "_"))');
swipl.call('assert(nip("_", "_"))');
swipl.call('assert(all("_", "_"))');
swipl.call('assert((allowed_to_send_email(Domain, IP) :- (ip(Domain, IP)), once(\\+ all(Domain, "-"); \\+ nip(Domain, IP))))');
const query = new swipl.Query(`allowed_to_send_email(${domain}, IP)`);
let ret = null;
let result = []
@ -48,6 +48,8 @@ const spf = (req, res) => {
result.push(`${ret.IP}`);
}
query.close();
swipl.cleanup()
swipl.initialise()
return res.status(200).send(result)
})
})