A
A
Anton2020-10-29 14:08:49
MySQL
Anton, 2020-10-29 14:08:49

How to make partial numbers in the blacklist taken into account?

There is such an entry in Asterisk - it blocks numbers from the MySql database.
The format of the numbers is indicated in full, such as
79001234567

[SubMysqlblacklist]
exten => s,1,NoOp(--- MACRO --- BLACKLIST ---)
same => n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
same => n,MySql(query resultid ${connid} select callerid from blacklist where callerid=${CALLERID(num)} and blockenabled = 1)
same => n,MySql(Fetch fetchid ${resultid} blacklistid)
same => n,NoOp(FetchID: ${fetchid} Var1: ${blacklistid} ConnID: ${connid} ResultID: ${resultid})
same => n,GotoIf($["${CALLERID(num)}" = "${blacklistid}"]?blacklisted)
same => n,MySql(clear ${resultid})
same => n,MySql(disconnect ${connid})
same => n,Goto(end)
same => n(blacklisted),Verbose(Cannot dial - ${CALLERID(num)} is blacklisted !)
same => n,MYSQL(clear ${resultid})
same => n,MYSQL(disconnect ${connid})
same => n,Progress()
same => n,Playback(/music/forblacklist,noanswer)
same => n,Wait(1)
same => n,Hangup()
same => n(end),NoOp(-- Clear --)
same => n,Return()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-10-29
@anton99zel

SELECT COUNT(*) FROM blacklist WHERE ${CALLERID(num)} LIKE CONCAT(callerid, '%') AND blockenabled = 1

And check that the number returned is greater than zero.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question