From 92ea3df4aa149118e1ecebe729cc48d944b2d2dc Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 4 Nov 2024 17:38:55 +0300 Subject: [PATCH 1/2] Removeearly return statement --- remote/accountservice.go | 1 - 1 file changed, 1 deletion(-) diff --git a/remote/accountservice.go b/remote/accountservice.go index 73052f6..2e19de1 100644 --- a/remote/accountservice.go +++ b/remote/accountservice.go @@ -202,7 +202,6 @@ func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKRespons if len(okResponse.Result) == 0 { return nil, errors.New("Empty api result") } - return &okResponse, nil v, err := json.Marshal(okResponse.Result) if err != nil { -- 2.45.2 From 266d3d06c3c86ec631b10011ca4e193ea1f367fe Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 4 Nov 2024 17:56:25 +0300 Subject: [PATCH 2/2] Check the flag_no_active_voucher before proceeding --- internal/handlers/ussd/menuhandler.go | 3 ++- services/registration/no_voucher | 2 +- services/registration/no_voucher_swa | 2 +- services/registration/select_voucher.vis | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index 6c1917d..ca4af09 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -1254,7 +1254,8 @@ func (h *Handlers) SetDefaultVoucher(ctx context.Context, sym string, input []by // Fetch vouchers from the API using the public key vouchersResp, err := h.accountService.FetchVouchers(ctx, string(publicKey)) if err != nil { - return res, err + res.FlagSet = append(res.FlagSet, flag_no_active_voucher) + return res, nil } // Return if there is no voucher diff --git a/services/registration/no_voucher b/services/registration/no_voucher index 332f00e..6303197 100644 --- a/services/registration/no_voucher +++ b/services/registration/no_voucher @@ -1 +1 @@ -You need a voucher to send \ No newline at end of file +You need a voucher to proceed \ No newline at end of file diff --git a/services/registration/no_voucher_swa b/services/registration/no_voucher_swa index 66e8f26..7291650 100644 --- a/services/registration/no_voucher_swa +++ b/services/registration/no_voucher_swa @@ -1 +1 @@ -Unahitaji sarafu kutuma \ No newline at end of file +Unahitaji sarafu kuendelea \ No newline at end of file diff --git a/services/registration/select_voucher.vis b/services/registration/select_voucher.vis index 08aa434..058d791 100644 --- a/services/registration/select_voucher.vis +++ b/services/registration/select_voucher.vis @@ -1,3 +1,4 @@ +CATCH no_voucher flag_no_active_voucher 1 LOAD get_vouchers 0 MAP get_vouchers MOUT back 0 -- 2.45.2