Compare commits
No commits in common. "9ad7d5a5226619eac07e99bcd4ffe1f3ec89548b" and "9ccb6cc066cbbb1f0da585d6d1f6f0941901b6e3" have entirely different histories.
9ad7d5a522
...
9ccb6cc066
@ -95,7 +95,6 @@ func (ls *LocalHandlerService) GetHandler() (*ussd.Handlers, error) {
|
||||
ls.DbRs.AddLocalFunc("check_vouchers", ussdHandlers.CheckVouchers)
|
||||
ls.DbRs.AddLocalFunc("get_vouchers", ussdHandlers.GetVoucherList)
|
||||
ls.DbRs.AddLocalFunc("view_voucher", ussdHandlers.ViewVoucher)
|
||||
ls.DbRs.AddLocalFunc("set_voucher", ussdHandlers.SetVoucher)
|
||||
|
||||
return ussdHandlers, nil
|
||||
}
|
||||
|
@ -1058,13 +1058,6 @@ func (h *Handlers) CheckVouchers(ctx context.Context, sym string, input []byte)
|
||||
func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
var err error
|
||||
store := h.userdataStore
|
||||
|
||||
sessionId, ok := ctx.Value("SessionId").(string)
|
||||
if !ok {
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
|
||||
inputStr := string(input)
|
||||
|
||||
if inputStr == "0" || inputStr == "99" {
|
||||
@ -1074,6 +1067,7 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r
|
||||
flag_incorrect_voucher, _ := h.flagManager.GetFlag("flag_incorrect_voucher")
|
||||
|
||||
// Initialize the store and prefix database
|
||||
store := h.userdataStore
|
||||
prefixdb := storage.NewSubPrefixDb(store, []byte("token_holdings"))
|
||||
|
||||
// Retrieve the voucher symbol list
|
||||
@ -1117,12 +1111,8 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r
|
||||
}
|
||||
}
|
||||
|
||||
// If a match is found, write the temporary sym , then return the symbol and balance
|
||||
// If a match is found, return the symbol and balance
|
||||
if matchedSymbol != "" && matchedBalance != "" {
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_SYM, []byte(matchedSymbol))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Content = fmt.Sprintf("%s\n%s", matchedSymbol, matchedBalance)
|
||||
res.FlagReset = append(res.FlagReset, flag_incorrect_voucher)
|
||||
} else {
|
||||
@ -1131,38 +1121,3 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// SetVoucher retrieves the temporary voucher, sets it as the active voucher and
|
||||
// clears the temporary voucher/sym
|
||||
func (h *Handlers) SetVoucher(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
var err error
|
||||
store := h.userdataStore
|
||||
|
||||
sessionId, ok := ctx.Value("SessionId").(string)
|
||||
if !ok {
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
|
||||
// get the current temporary symbol
|
||||
temporarySym, err := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_SYM)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
// set the active symbol
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_ACTIVE_SYM, []byte(temporarySym))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
// reset the temporary symbol
|
||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_SYM, []byte(""))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.Content = string(temporarySym)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
@ -24,8 +24,6 @@ const (
|
||||
DATA_AMOUNT
|
||||
DATA_TEMPORARY_PIN
|
||||
DATA_VOUCHER_LIST
|
||||
DATA_TEMPORARY_SYM
|
||||
DATA_ACTIVE_SYM
|
||||
)
|
||||
|
||||
func typToBytes(typ DataTyp) []byte {
|
||||
|
@ -1 +1 @@
|
||||
Success! {{.set_voucher}} is now your active voucher.
|
||||
Success! symbol is now your active voucher.
|
@ -1,5 +1,3 @@
|
||||
LOAD set_voucher 12
|
||||
MAP set_voucher
|
||||
MOUT back 0
|
||||
MOUT quit 9
|
||||
HALT
|
||||
|
@ -1 +1 @@
|
||||
Hongera! {{.set_voucher}} ni Sarafu inayotumika sasa.
|
||||
Hongera! symbol ni Sarafu inayotumika sasa.
|
Loading…
Reference in New Issue
Block a user