Compare commits
No commits in common. "60134f14e9bc0fe9e5f85645623f09338219b0e7" and "4c339450810a8ee212b2fe464fac847f567f7ad8" have entirely different histories.
60134f14e9
...
4c33945081
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,5 +4,3 @@ go.work*
|
|||||||
**/*/*.bin
|
**/*/*.bin
|
||||||
**/*/.state/
|
**/*/.state/
|
||||||
cmd/.state/
|
cmd/.state/
|
||||||
id_*
|
|
||||||
*.gdbm
|
|
||||||
|
@ -88,6 +88,7 @@ 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)
|
||||||
|
@ -117,14 +117,17 @@ 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
|
||||||
|
|
||||||
symbol, _ := h.st.Where()
|
sym, _ = h.st.Where()
|
||||||
code := strings.Split(symbol, "_")[1]
|
|
||||||
|
|
||||||
if !utils.IsValidISO639(code) {
|
switch sym {
|
||||||
return res, nil
|
case "set_default":
|
||||||
|
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 {
|
||||||
@ -313,6 +316,32 @@ 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
|
||||||
@ -443,7 +472,6 @@ 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)
|
||||||
@ -451,11 +479,21 @@ func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (re
|
|||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
|
||||||
gender := strings.Split(symbol, "_")[1]
|
if len(input) > 0 {
|
||||||
store := h.userdataStore
|
gender := string(input)
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_GENDER, []byte(gender))
|
switch gender {
|
||||||
if err != nil {
|
case "1":
|
||||||
return res, nil
|
gender = "Male"
|
||||||
|
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
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
var isoCodes = map[string]bool{
|
|
||||||
"eng": true, // English
|
|
||||||
"swa": true, // Swahili
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsValidISO639(code string) bool {
|
|
||||||
return isoCodes[code]
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
Something went wrong.Please try again
|
|
@ -1 +0,0 @@
|
|||||||
HALT
|
|
@ -11,6 +11,8 @@ 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
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
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 set_male 1
|
INCMP pin_entry *
|
||||||
INCMP set_female 2
|
|
||||||
INCMP set_unspecified 3
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
MOUT english 0
|
MOUT english 0
|
||||||
MOUT kiswahili 1
|
MOUT kiswahili 1
|
||||||
HALT
|
HALT
|
||||||
INCMP set_eng 0
|
INCMP set_default 0
|
||||||
INCMP set_swa 1
|
INCMP set_swa 1
|
||||||
INCMP . *
|
INCMP . *
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
LOAD save_gender 0
|
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
||||||
MOVE pin_entry
|
|
@ -1,4 +0,0 @@
|
|||||||
LOAD save_gender 0
|
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
||||||
MOVE pin_entry
|
|
@ -1,4 +0,0 @@
|
|||||||
LOAD save_gender 0
|
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
||||||
MOVE pin_entry
|
|
Loading…
Reference in New Issue
Block a user