Is This A Reasonable Way To Store User Prefs In ASTDB? And What’s This Is JSON A Dialplan “thing” Yet? (Asterisk 14)
Thanks.
OK, this is the best I can come up with on Asterisk 14 to store an unknown number of user preferences in ASTDB.
Is this acceptable? Is there a better way? And… what’s this error about?
[Nov 5 16:05:56] NOTICE[1936][C-0000002b]: ast_expr2.y:763
compose_func_args: argbuf allocated 17 bytes;
[Nov 5 16:05:56] NOTICE[1936][C-0000002b]: ast_expr2.y:782
compose_func_args: argbuf uses 16 bytes;
It seems to be triggered the following line, even though the result is correct.
Set(HASH(userPrefs,volume)=$[HASH(userPrefs,volume)+1])
The result “database show” after running it twice is as expected:
/userPrefs/6001 :
volume:3,location:London,language:en_GB
Here’s my test dialplan:
[dbPrefStoreTest]
exten => s,1,NoOp()
same => n,GotoIf($[${DB_EXISTS(userPrefs/${CALLERID(num)})}]?getprefs)
same => n,Set(DB(userPrefs/${CALLERID(num)})=volume:1,location:London,language:en_GB)
same => n,Verbose(1,)
same => n,Verbose(1,———-Get Items from DB————)
same => n(getprefs),Set(userPrefs=${DB(userPrefs/${CALLERID(num)})})
same => n,While($[“${SET(mytmpvar=${SHIFT(userPrefs)})}” != “”])
same => n,Set(HASH(userPrefs,${CUT(mytmpvar,:,1)})=${CUT(mytmpvar,:,2)})
same => n,EndWhile
same => n,Verbose(1,hashKeys(userPrefs) are “${HASHKEYS(userPrefs)}”
and “HASH(userPrefs)” is “${HASH(userPrefs)}”)
same => n,Verbose(1,)
same => n,Verbose(1,———-Increase the volume by 1—-)
same => n,Set(HASH(userPrefs,volume)=$[HASH(userPrefs,volume)+1])
same => n,Verbose(1,NOW hashKeys(userPrefs) are
“${HASHKEYS(userPrefs)}” and “HASH(userPrefs)” is
“${HASH(userPrefs)}”)
same => n,Verbose(1,)
same => n,Verbose(1,———-Bundle them back up for DB storage—-)
same => n,Set(hUP=${HASHKEYS(userPrefs)})
same => n,While($[“${SET(hashKey=${SHIFT(hUP)})}” != “”])
same => n,Set(PUSH(prefPairs)=${hashKey}:${HASH(userPrefs,${hashKey})})
same => n,Verbose(1,Current item is
${hashKey}:${HASH(userPrefs,${hashKey})})
same => n,EndWhile
same => n,Verbose(1,Setting ${prefPairs} to DB)
same => n,Set(DB(userPrefs/${CALLERID(num)})=${prefPairs})
same => n,Hangup()