Compare commits

..

26 Commits

Author SHA1 Message Date
a8b202bd79 Merge branch 'master' into menu-profile-edit 2024-09-25 15:19:04 +02:00
Carlosokumu
6dbd250694 remove extra spaces 2024-09-25 09:29:26 +03:00
Carlosokumu
cc760e7698 remove move 2024-09-25 09:20:45 +03:00
Carlosokumu
8648ea599c add catch node 2024-09-25 09:20:45 +03:00
alfred-mk
77e4c5d43a reset the positon of LOAD function 2024-09-25 09:20:44 +03:00
alfred-mk
b15ba367c4 change position of LOAD function 2024-09-25 09:20:44 +03:00
alfred-mk
4db862bc97 LOAD and RELOAD get_amount 2024-09-25 09:20:43 +03:00
alfred-mk
6ad67f6adc change position of LOAD 2024-09-25 09:20:42 +03:00
0caf82a27e Merge pull request 'fix-repeated-nodes' (#81) from fix-repeated-nodes into master
Reviewed-on: urdt/ussd#81
Reviewed-by: lash <accounts-grassrootseconomics@holbrook.no>
2024-09-25 01:48:34 +02:00
a430857309 Merge branch 'master' into fix-repeated-nodes 2024-09-25 01:41:43 +02:00
alfred-mk
2643c0c9ff only have a -d for the engineDebug 2024-09-24 16:11:22 +03:00
alfred-mk
b8852e1ab3 add engineDebug and stateDebug flags 2024-09-24 14:10:10 +03:00
Carlosokumu
0dea34daab resolve confilict 2024-09-24 09:18:21 +03:00
Carlosokumu
8057313c78 Merge remote-tracking branch 'remotes/origin/master' into menu-profile-edit 2024-09-24 09:10:17 +03:00
Carlosokumu
1bd96d0689 setup dedicated nodes for case selection 2024-09-24 09:02:04 +03:00
Carlosokumu
bbfe46f162 use current rendering symbol for case selection 2024-09-24 09:01:19 +03:00
Carlosokumu
eff2cbde8b setup check for unused code 2024-09-24 09:00:31 +03:00
Carlosokumu
5c85ecffd1 remove unused code 2024-09-24 09:00:13 +03:00
e9fdd1ddbe Merge pull request 'Threaded gdbm' (#76) from lash/thread-gdbm into master
Reviewed-on: urdt/ussd#76
2024-09-23 21:25:37 +02:00
alfred-mk
8a03b05c90 reset the positon of LOAD function 2024-09-23 21:20:57 +03:00
alfred-mk
5a38b40eaf Merge branch 'lash/thread-gdbm' into fix-repeated-nodes 2024-09-23 20:55:56 +03:00
alfred-mk
909d1f3409 change position of LOAD function 2024-09-23 14:16:01 +03:00
alfred-mk
66cf90f044 LOAD and RELOAD get_amount 2024-09-23 14:13:26 +03:00
alfred-mk
74d5da3987 Merge branch 'lash/thread-gdbm' into fix-repeated-nodes 2024-09-23 11:40:29 +03:00
alfred-mk
f215159725 change position of LOAD 2024-09-23 11:38:07 +03:00
alfred-mk
a6301163eb use latest commit from go-vise 0.2.0 2024-09-23 09:59:21 +03:00
21 changed files with 59 additions and 83 deletions

View File

@@ -69,13 +69,11 @@ func main() {
var resourceDir string var resourceDir string
var size uint var size uint
var engineDebug bool var engineDebug bool
var stateDebug bool
var host string var host string
var port uint var port uint
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir") flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output") flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
flag.UintVar(&size, "s", 160, "max size of output") flag.UintVar(&size, "s", 160, "max size of output")
flag.StringVar(&host, "h", "127.0.0.1", "http host") flag.StringVar(&host, "h", "127.0.0.1", "http host")
flag.UintVar(&port, "p", 7123, "http port") flag.UintVar(&port, "p", 7123, "http port")
@@ -91,9 +89,7 @@ func main() {
OutputSize: uint32(size), OutputSize: uint32(size),
FlagCount: uint32(16), FlagCount: uint32(16),
} }
if stateDebug {
cfg.StateDebug = true
}
if engineDebug { if engineDebug {
cfg.EngineDebug = true cfg.EngineDebug = true
} }

View File

@@ -41,14 +41,12 @@ func main() {
var resourceDir string var resourceDir string
var size uint var size uint
var engineDebug bool var engineDebug bool
var stateDebug bool
var host string var host string
var port uint var port uint
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir") flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output") flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
flag.UintVar(&size, "s", 160, "max size of output") flag.UintVar(&size, "s", 160, "max size of output")
flag.StringVar(&host, "h", "127.0.0.1", "http host") flag.StringVar(&host, "h", "127.0.0.1", "http host")
flag.UintVar(&port, "p", 7123, "http port") flag.UintVar(&port, "p", 7123, "http port")
@@ -64,9 +62,7 @@ func main() {
OutputSize: uint32(size), OutputSize: uint32(size),
FlagCount: uint32(16), FlagCount: uint32(16),
} }
if stateDebug {
cfg.StateDebug = true
}
if engineDebug { if engineDebug {
cfg.EngineDebug = true cfg.EngineDebug = true
} }

View File

@@ -30,13 +30,11 @@ func main() {
var resourceDir string var resourceDir string
var size uint var size uint
var engineDebug bool var engineDebug bool
var stateDebug bool
var host string var host string
var port uint var port uint
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir") flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output") flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
flag.UintVar(&size, "s", 160, "max size of output") flag.UintVar(&size, "s", 160, "max size of output")
flag.StringVar(&host, "h", "127.0.0.1", "http host") flag.StringVar(&host, "h", "127.0.0.1", "http host")
flag.UintVar(&port, "p", 7123, "http port") flag.UintVar(&port, "p", 7123, "http port")
@@ -52,9 +50,7 @@ func main() {
OutputSize: uint32(size), OutputSize: uint32(size),
FlagCount: uint32(16), FlagCount: uint32(16),
} }
if stateDebug {
cfg.StateDebug = true
}
if engineDebug { if engineDebug {
cfg.EngineDebug = true cfg.EngineDebug = true
} }

View File

@@ -23,10 +23,10 @@ func main() {
var dbDir string var dbDir string
var size uint var size uint
var sessionId string var sessionId string
var debug bool var engineDebug bool
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
flag.BoolVar(&debug, "d", false, "use engine debug output") flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
flag.UintVar(&size, "s", 160, "max size of output") flag.UintVar(&size, "s", 160, "max size of output")
flag.Parse() flag.Parse()
@@ -93,7 +93,7 @@ func main() {
en := lhs.GetEngine() en := lhs.GetEngine()
en = en.WithFirst(hl.Init) en = en.WithFirst(hl.Init)
if debug { if engineDebug {
en = en.WithDebug(nil) en = en.WithDebug(nil)
} }

View File

@@ -88,7 +88,6 @@ func (ls *LocalHandlerService) GetHandler() (*ussd.Handlers, error) {
ls.DbRs.AddLocalFunc("get_profile_info", ussdHandlers.GetProfileInfo) ls.DbRs.AddLocalFunc("get_profile_info", ussdHandlers.GetProfileInfo)
ls.DbRs.AddLocalFunc("verify_yob", ussdHandlers.VerifyYob) ls.DbRs.AddLocalFunc("verify_yob", ussdHandlers.VerifyYob)
ls.DbRs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob) ls.DbRs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
ls.DbRs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
ls.DbRs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction) ls.DbRs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
ls.DbRs.AddLocalFunc("save_temporary_pin", ussdHandlers.SaveTemporaryPin) ls.DbRs.AddLocalFunc("save_temporary_pin", ussdHandlers.SaveTemporaryPin)
ls.DbRs.AddLocalFunc("verify_new_pin", ussdHandlers.VerifyNewPin) ls.DbRs.AddLocalFunc("verify_new_pin", ussdHandlers.VerifyNewPin)

View File

@@ -117,17 +117,14 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource
func (h *Handlers) SetLanguage(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (h *Handlers) SetLanguage(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result var res resource.Result
sym, _ = h.st.Where() symbol, _ := h.st.Where()
code := strings.Split(symbol, "_")[1]
switch sym { if !utils.IsValidISO639(code) {
case "set_default": return res, nil
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
res.Content = "eng"
case "set_swa":
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
res.Content = "swa"
default:
} }
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
res.Content = code
languageSetFlag, err := h.flagManager.GetFlag("flag_language_set") languageSetFlag, err := h.flagManager.GetFlag("flag_language_set")
if err != nil { if err != nil {
@@ -279,32 +276,6 @@ func (h *Handlers) ConfirmPinChange(ctx context.Context, sym string, input []byt
return res, nil return res, nil
} }
// SetResetSingleEdit sets and resets flags to allow gradual editing of profile information.
func (h *Handlers) SetResetSingleEdit(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
menuOption := string(input)
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
flag_single_edit, _ := h.flagManager.GetFlag("flag_single_edit")
switch menuOption {
case "2":
res.FlagReset = append(res.FlagReset, flag_allow_update)
res.FlagSet = append(res.FlagSet, flag_single_edit)
case "3":
res.FlagReset = append(res.FlagReset, flag_allow_update)
res.FlagSet = append(res.FlagSet, flag_single_edit)
case "4":
res.FlagReset = append(res.FlagReset, flag_allow_update)
res.FlagSet = append(res.FlagSet, flag_single_edit)
default:
res.FlagReset = append(res.FlagReset, flag_single_edit)
}
return res, nil
}
// VerifyPin checks whether the confirmation PIN is similar to the account PIN // VerifyPin checks whether the confirmation PIN is similar to the account PIN
// If similar, it sets the USERFLAG_PIN_SET flag allowing the user // If similar, it sets the USERFLAG_PIN_SET flag allowing the user
// to access the main menu // to access the main menu
@@ -435,6 +406,7 @@ func (h *Handlers) SaveLocation(ctx context.Context, sym string, input []byte) (
// SaveGender updates the gender in the gdbm with the provided input. // SaveGender updates the gender in the gdbm with the provided input.
func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (resource.Result, error) {
symbol, _ := h.st.Where()
var res resource.Result var res resource.Result
var err error var err error
sessionId, ok := ctx.Value("SessionId").(string) sessionId, ok := ctx.Value("SessionId").(string)
@@ -442,21 +414,11 @@ func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (re
return res, fmt.Errorf("missing session") return res, fmt.Errorf("missing session")
} }
if len(input) > 0 { gender := strings.Split(symbol, "_")[1]
gender := string(input) store := h.userdataStore
switch gender { err = store.WriteEntry(ctx, sessionId, utils.DATA_GENDER, []byte(gender))
case "1": if err != nil {
gender = "Male" return res, nil
case "2":
gender = "Female"
case "3":
gender = "Unspecified"
}
store := h.userdataStore
err = store.WriteEntry(ctx, sessionId, utils.DATA_GENDER, []byte(gender))
if err != nil {
return res, nil
}
} }
return res, nil return res, nil

11
internal/utils/isocode.go Normal file
View File

@@ -0,0 +1,11 @@
package utils
var isoCodes = map[string]bool{
"eng": true, // English
"swa": true, // Swahili
}
func IsValidISO639(code string) bool {
return isoCodes[code]
}

View File

@@ -0,0 +1 @@
Something went wrong.Please try again

View File

@@ -0,0 +1 @@
HALT

View File

@@ -9,4 +9,5 @@ CATCH invalid_amount flag_invalid_amount 1
INCMP _ 0 INCMP _ 0
LOAD get_recipient 12 LOAD get_recipient 12
LOAD get_sender 64 LOAD get_sender 64
LOAD get_amount 12
INCMP transaction_pin * INCMP transaction_pin *

View File

@@ -11,8 +11,6 @@ MOUT view 7
MOUT back 0 MOUT back 0
HALT HALT
INCMP my_account 0 INCMP my_account 0
LOAD set_reset_single_edit 0
RELOAD set_reset_single_edit
INCMP enter_name 1 INCMP enter_name 1
INCMP enter_familyname 2 INCMP enter_familyname 2
INCMP select_gender 3 INCMP select_gender 3

View File

@@ -1,13 +1,15 @@
CATCH incorrect_pin flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
CATCH profile_update_success flag_allow_update 1 CATCH profile_update_success flag_allow_update 1
LOAD save_gender 0
MOUT male 1 MOUT male 1
MOUT female 2 MOUT female 2
MOUT unspecified 3 MOUT unspecified 3
MOUT back 0 MOUT back 0
HALT HALT
RELOAD save_gender
INCMP _ 0 INCMP _ 0
INCMP pin_entry * INCMP set_male 1
INCMP set_female 2
INCMP set_unspecified 3

View File

@@ -1,6 +1,6 @@
MOUT english 0 MOUT english 0
MOUT kiswahili 1 MOUT kiswahili 1
HALT HALT
INCMP set_default 0 INCMP set_eng 0
INCMP set_swa 1 INCMP set_swa 1
INCMP . * INCMP . *

View File

@@ -0,0 +1,4 @@
LOAD save_gender 0
CATCH incorrect_pin flag_incorrect_pin 1
CATCH profile_update_success flag_allow_update 1
MOVE pin_entry

View File

@@ -0,0 +1,4 @@
LOAD save_gender 0
CATCH incorrect_pin flag_incorrect_pin 1
CATCH profile_update_success flag_allow_update 1
MOVE pin_entry

View File

@@ -0,0 +1,4 @@
LOAD save_gender 0
CATCH incorrect_pin flag_incorrect_pin 1
CATCH profile_update_success flag_allow_update 1
MOVE pin_entry

View File

@@ -1,7 +1,7 @@
LOAD reset_incorrect 6 LOAD reset_incorrect 6
CATCH incorrect_pin flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
CATCH _ flag_account_authorized 0 CATCH _ flag_account_authorized 0
LOAD get_amount 10 RELOAD get_amount
MAP get_amount MAP get_amount
RELOAD get_recipient RELOAD get_recipient
MAP get_recipient MAP get_recipient

View File

@@ -1,2 +1,2 @@
{{.get_recipient}} will receive {{.validate_amount}} from {{.get_sender}} {{.get_recipient}} will receive {{.get_amount}} from {{.get_sender}}
Please enter your PIN to confirm: Please enter your PIN to confirm:

View File

@@ -1,12 +1,13 @@
MAP validate_amount RELOAD get_amount
MAP get_amount
RELOAD get_recipient RELOAD get_recipient
MAP get_recipient MAP get_recipient
RELOAD get_sender RELOAD get_sender
MAP get_sender MAP get_sender
MOUT back 0 MOUT back 0
MOUT quit 9 MOUT quit 9
HALT
LOAD authorize_account 6 LOAD authorize_account 6
HALT
RELOAD authorize_account RELOAD authorize_account
CATCH incorrect_pin flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
INCMP _ 0 INCMP _ 0

View File

@@ -1,2 +1,2 @@
{{.get_recipient}} atapokea {{.validate_amount}} kutoka kwa {{.get_sender}} {{.get_recipient}} atapokea {{.get_amount}} kutoka kwa {{.get_sender}}
Tafadhali weka PIN yako kudhibitisha: Tafadhali weka PIN yako kudhibitisha: