Compare commits
No commits in common. "d25128287e5644f89a2199a619a87dcbb654df90" and "843b0d1e7efd89aba6364db5d75e21c1dbfff692" have entirely different histories.
d25128287e
...
843b0d1e7e
@ -19,9 +19,9 @@ import (
|
|||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/persist"
|
||||||
"git.defalsify.org/vise.git/resource"
|
"git.defalsify.org/vise.git/resource"
|
||||||
"git.defalsify.org/vise.git/state"
|
"git.defalsify.org/vise.git/state"
|
||||||
"git.grassecon.net/urdt/ussd/common"
|
|
||||||
"git.grassecon.net/urdt/ussd/internal/handlers/server"
|
"git.grassecon.net/urdt/ussd/internal/handlers/server"
|
||||||
"git.grassecon.net/urdt/ussd/internal/utils"
|
"git.grassecon.net/urdt/ussd/internal/utils"
|
||||||
|
"git.grassecon.net/urdt/ussd/common"
|
||||||
"gopkg.in/leonelquinteros/gotext.v1"
|
"gopkg.in/leonelquinteros/gotext.v1"
|
||||||
|
|
||||||
"git.grassecon.net/urdt/ussd/internal/storage"
|
"git.grassecon.net/urdt/ussd/internal/storage"
|
||||||
@ -33,6 +33,7 @@ var (
|
|||||||
translationDir = path.Join(scriptDir, "locale")
|
translationDir = path.Join(scriptDir, "locale")
|
||||||
okResponse *api.OKResponse
|
okResponse *api.OKResponse
|
||||||
errResponse *api.ErrResponse
|
errResponse *api.ErrResponse
|
||||||
|
backOption = []byte("0")
|
||||||
)
|
)
|
||||||
|
|
||||||
// FlagManager handles centralized flag management
|
// FlagManager handles centralized flag management
|
||||||
@ -328,18 +329,13 @@ func (h *Handlers) SaveFirstname(ctx context.Context, sym string, input []byte)
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
firstName := string(input)
|
if len(input) > 0 {
|
||||||
store := h.userdataStore
|
if bytes.Equal(input, backOption) {
|
||||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
return res, nil
|
||||||
allowUpdate := h.st.MatchFlag(flag_allow_update, true)
|
|
||||||
if allowUpdate {
|
|
||||||
temporaryFirstName, _ := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_FIRST_NAME)
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_FIRST_NAME, []byte(temporaryFirstName))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
}
|
||||||
} else {
|
firstName := string(input)
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_FIRST_NAME, []byte(firstName))
|
store := h.userdataStore
|
||||||
|
err = store.WriteEntry(ctx, sessionId, utils.DATA_FIRST_NAME, []byte(firstName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@ -356,24 +352,20 @@ func (h *Handlers) SaveFamilyname(ctx context.Context, sym string, input []byte)
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
store := h.userdataStore
|
if len(input) > 0 {
|
||||||
familyName := string(input)
|
if bytes.Equal(input, backOption) {
|
||||||
|
return res, nil
|
||||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
}
|
||||||
allowUpdate := h.st.MatchFlag(flag_allow_update, true)
|
familyName := string(input)
|
||||||
|
store := h.userdataStore
|
||||||
if allowUpdate {
|
err = store.WriteEntry(ctx, sessionId, utils.DATA_FAMILY_NAME, []byte(familyName))
|
||||||
temporaryFamilyName, _ := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_FAMILY_NAME)
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_FAMILY_NAME, []byte(temporaryFamilyName))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_FAMILY_NAME, []byte(familyName))
|
return res, fmt.Errorf("a family name cannot be less than one character")
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,19 +377,10 @@ func (h *Handlers) SaveYob(ctx context.Context, sym string, input []byte) (resou
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
yob := string(input)
|
if len(input) == 4 {
|
||||||
store := h.userdataStore
|
yob := string(input)
|
||||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
store := h.userdataStore
|
||||||
allowUpdate := h.st.MatchFlag(flag_allow_update, true)
|
err = store.WriteEntry(ctx, sessionId, utils.DATA_YOB, []byte(yob))
|
||||||
|
|
||||||
if allowUpdate {
|
|
||||||
temporaryYob, _ := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_YOB)
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_YOB, []byte(temporaryYob))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_YOB, []byte(yob))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@ -414,20 +397,13 @@ func (h *Handlers) SaveLocation(ctx context.Context, sym string, input []byte) (
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
location := string(input)
|
if len(input) > 0 {
|
||||||
store := h.userdataStore
|
if bytes.Equal(input, backOption) {
|
||||||
|
return res, nil
|
||||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
|
||||||
allowUpdate := h.st.MatchFlag(flag_allow_update, true)
|
|
||||||
|
|
||||||
if allowUpdate {
|
|
||||||
temporaryLocation, _ := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_LOCATION)
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_LOCATION, []byte(temporaryLocation))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
}
|
||||||
} else {
|
location := string(input)
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_LOCATION, []byte(location))
|
store := h.userdataStore
|
||||||
|
err = store.WriteEntry(ctx, sessionId, utils.DATA_LOCATION, []byte(location))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@ -445,22 +421,14 @@ func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (re
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
if bytes.Equal(input, backOption) {
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
gender := strings.Split(symbol, "_")[1]
|
gender := strings.Split(symbol, "_")[1]
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
err = store.WriteEntry(ctx, sessionId, utils.DATA_GENDER, []byte(gender))
|
||||||
allowUpdate := h.st.MatchFlag(flag_allow_update, true)
|
if err != nil {
|
||||||
|
return res, nil
|
||||||
if allowUpdate {
|
|
||||||
temporaryGender, _ := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_GENDER)
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_GENDER, []byte(temporaryGender))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_GENDER, []byte(gender))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
@ -474,22 +442,12 @@ func (h *Handlers) SaveOfferings(ctx context.Context, sym string, input []byte)
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
offerings := string(input)
|
if len(input) > 0 {
|
||||||
store := h.userdataStore
|
offerings := string(input)
|
||||||
|
store := h.userdataStore
|
||||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
err = store.WriteEntry(ctx, sessionId, utils.DATA_OFFERINGS, []byte(offerings))
|
||||||
allowUpdate := h.st.MatchFlag(flag_allow_update, true)
|
|
||||||
|
|
||||||
if allowUpdate {
|
|
||||||
temporaryOfferings, _ := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_OFFERINGS)
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_OFFERINGS, []byte(temporaryOfferings))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, nil
|
||||||
}
|
|
||||||
} else {
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_OFFERINGS, []byte(offerings))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,17 +14,11 @@ const (
|
|||||||
DATA_CUSTODIAL_ID
|
DATA_CUSTODIAL_ID
|
||||||
DATA_ACCOUNT_PIN
|
DATA_ACCOUNT_PIN
|
||||||
DATA_ACCOUNT_STATUS
|
DATA_ACCOUNT_STATUS
|
||||||
DATA_TEMPORARY_FIRST_NAME
|
|
||||||
DATA_FIRST_NAME
|
DATA_FIRST_NAME
|
||||||
DATA_TEMPORARY_FAMILY_NAME
|
|
||||||
DATA_FAMILY_NAME
|
DATA_FAMILY_NAME
|
||||||
DATA_TEMPORARY_YOB
|
|
||||||
DATA_YOB
|
DATA_YOB
|
||||||
DATA_TEMPORARY_LOCATION
|
|
||||||
DATA_LOCATION
|
DATA_LOCATION
|
||||||
DATA_TEMPORARY_GENDER
|
|
||||||
DATA_GENDER
|
DATA_GENDER
|
||||||
DATA_TEMPORARY_OFFERINGS
|
|
||||||
DATA_OFFERINGS
|
DATA_OFFERINGS
|
||||||
DATA_RECIPIENT
|
DATA_RECIPIENT
|
||||||
DATA_AMOUNT
|
DATA_AMOUNT
|
||||||
@ -35,7 +29,6 @@ const (
|
|||||||
DATA_TEMPORARY_BAL
|
DATA_TEMPORARY_BAL
|
||||||
DATA_ACTIVE_BAL
|
DATA_ACTIVE_BAL
|
||||||
DATA_PUBLIC_KEY_REVERSE
|
DATA_PUBLIC_KEY_REVERSE
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func typToBytes(typ DataTyp) []byte {
|
func typToBytes(typ DataTyp) []byte {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_familyname flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
LOAD save_familyname 0
|
LOAD save_familyname 0
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_location flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
LOAD save_location 0
|
LOAD save_location 0
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_firstname flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
LOAD save_firstname 0
|
LOAD save_firstname 0
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_offerings flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
LOAD save_offerings 0
|
LOAD save_offerings 0
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_yob flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
|
LOAD save_yob 0
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
LOAD verify_yob 0
|
LOAD verify_yob 0
|
||||||
CATCH incorrect_date_format flag_incorrect_date_format 1
|
CATCH incorrect_date_format flag_incorrect_date_format 1
|
||||||
LOAD save_yob 0
|
|
||||||
RELOAD save_yob
|
RELOAD save_yob
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
INCMP pin_entry *
|
INCMP pin_entry *
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
LOAD save_gender 0
|
LOAD save_gender 0
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_gender flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
MOVE pin_entry
|
MOVE pin_entry
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
LOAD save_gender 0
|
LOAD save_gender 0
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_gender flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
MOVE pin_entry
|
MOVE pin_entry
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
LOAD save_gender 0
|
LOAD save_gender 0
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH update_gender flag_allow_update 1
|
CATCH profile_update_success flag_allow_update 1
|
||||||
MOVE pin_entry
|
MOVE pin_entry
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
RELOAD save_yob
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
@ -1,2 +0,0 @@
|
|||||||
RELOAD save_familyname
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
@ -1,2 +0,0 @@
|
|||||||
RELOAD save_firstname
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
@ -1,2 +0,0 @@
|
|||||||
RELOAD save_gender
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
@ -1,2 +0,0 @@
|
|||||||
RELOAD save_location
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
@ -1,2 +0,0 @@
|
|||||||
RELOAD save_offerings
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
@ -1,2 +0,0 @@
|
|||||||
RELOAD save_yob
|
|
||||||
CATCH profile_update_success flag_allow_update 1
|
|
Loading…
Reference in New Issue
Block a user