Compare commits

...

22 Commits

Author SHA1 Message Date
8c13e44a15 Merge pull request 'profile-edit-show' (#171) from profile-edit-show into master
Reviewed-on: #171
Reviewed-by: Alfred Kamanda <alfredkamandamw@gmail.com>
2024-11-14 09:27:42 +01:00
345dfbaa21
Merge remote-tracking branch 'refs/remotes/origin/profile-edit-show' into profile-edit-show 2024-11-14 11:01:42 +03:00
381e581e8e
add terminal logs 2024-11-14 11:00:12 +03:00
94d2e8203f
reload verify yob 2024-11-14 10:53:20 +03:00
f9e51618c5
remove extra line 2024-11-14 10:29:22 +03:00
f97ad2a262
use 1 for retry 2024-11-14 10:25:42 +03:00
59b14301ad Merge branch 'master' into profile-edit-show 2024-11-14 10:08:25 +03:00
fd2486b5cf
Merge branch 'terminal-logs' into profile-edit-show 2024-11-13 21:04:40 +03:00
97741b113b
Merge branch 'master' into profile-edit-show 2024-11-11 11:03:01 +03:00
9ebfb643aa
remove unused import 2024-11-08 17:28:20 +03:00
0aad21a52c
Merge branch 'master' into profile-edit-show 2024-11-08 17:21:27 +03:00
68d1628546
replace - with: Not provided 2024-11-08 17:19:41 +03:00
f4f95b3292
add some spacing 2024-11-08 17:15:27 +03:00
fc8915ea33
add http logging 2024-11-07 16:35:58 +03:00
cc36ddcb6d
add handler for showing the currently set profile information 2024-11-07 12:02:03 +03:00
f3388aef31
use _ for back 2024-11-07 11:59:12 +03:00
4e170b25e2
show currently set profile information 2024-11-07 11:58:58 +03:00
3e258a35fa
show currently set profile information 2024-11-07 11:58:25 +03:00
f66609bbae
add helper for getting db key from string 2024-11-07 09:18:11 +03:00
ebdc7b200a
register handler for getting current profile information 2024-11-07 09:16:49 +03:00
29e1e912d7
use edit prefix on each profile edit node 2024-11-06 17:52:22 +03:00
308f3327d0
use edit prefix on each profile edit information 2024-11-06 17:48:50 +03:00
38 changed files with 165 additions and 25 deletions

View File

@ -2,6 +2,7 @@ package common
import ( import (
"encoding/binary" "encoding/binary"
"errors"
"git.defalsify.org/vise.git/logging" "git.defalsify.org/vise.git/logging"
) )
@ -48,3 +49,23 @@ func PackKey(typ DataTyp, data []byte) []byte {
v := typToBytes(typ) v := typToBytes(typ)
return append(v, data...) return append(v, data...)
} }
func StringToDataTyp(str string) (DataTyp, error) {
switch str {
case "DATA_FIRST_NAME":
return DATA_FIRST_NAME, nil
case "DATA_FAMILY_NAME":
return DATA_FAMILY_NAME, nil
case "DATA_YOB":
return DATA_YOB, nil
case "DATA_LOCATION":
return DATA_LOCATION, nil
case "DATA_GENDER":
return DATA_GENDER, nil
case "DATA_OFFERINGS":
return DATA_OFFERINGS, nil
default:
return 0, errors.New("invalid DataTyp string")
}
}

View File

@ -115,6 +115,7 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountServiceIn
ls.DbRs.AddLocalFunc("reset_unregistered_number", ussdHandlers.ResetUnregisteredNumber) ls.DbRs.AddLocalFunc("reset_unregistered_number", ussdHandlers.ResetUnregisteredNumber)
ls.DbRs.AddLocalFunc("reset_others_pin", ussdHandlers.ResetOthersPin) ls.DbRs.AddLocalFunc("reset_others_pin", ussdHandlers.ResetOthersPin)
ls.DbRs.AddLocalFunc("save_others_temporary_pin", ussdHandlers.SaveOthersTemporaryPin) ls.DbRs.AddLocalFunc("save_others_temporary_pin", ussdHandlers.SaveOthersTemporaryPin)
ls.DbRs.AddLocalFunc("get_current_profile_info", ussdHandlers.GetCurrentProfileInfo)
return ussdHandlers, nil return ussdHandlers, nil
} }

View File

@ -1190,6 +1190,101 @@ func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []
return res, nil return res, nil
} }
func (h *Handlers) GetCurrentProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
var profileInfo []byte
var err error
sessionId, ok := ctx.Value("SessionId").(string)
if !ok {
return res, fmt.Errorf("missing session")
}
sm, _ := h.st.Where()
parts := strings.SplitN(sm, "_", 2)
filename := parts[1]
dbKeyStr := "DATA_" + strings.ToUpper(filename)
dbKey, err := common.StringToDataTyp(dbKeyStr)
if err != nil {
return res, err
}
store := h.userdataStore
switch dbKey {
case common.DATA_FIRST_NAME:
profileInfo, err = store.ReadEntry(ctx, sessionId, common.DATA_FIRST_NAME)
if err != nil {
if db.IsNotFound(err) {
res.Content = "Not provided"
break
}
logg.ErrorCtxf(ctx, "Failed to read first name entry with", "key", "error", common.DATA_FIRST_NAME, err)
return res, err
}
res.Content = string(profileInfo)
case common.DATA_FAMILY_NAME:
profileInfo, err = store.ReadEntry(ctx, sessionId, common.DATA_FAMILY_NAME)
if err != nil {
if db.IsNotFound(err) {
res.Content = "Not provided"
break
}
logg.ErrorCtxf(ctx, "Failed to read family name entry with", "key", "error", common.DATA_FAMILY_NAME, err)
return res, err
}
res.Content = string(profileInfo)
case common.DATA_GENDER:
profileInfo, err = store.ReadEntry(ctx, sessionId, common.DATA_GENDER)
if err != nil {
if db.IsNotFound(err) {
res.Content = "Not provided"
break
}
logg.ErrorCtxf(ctx, "Failed to read gender entry with", "key", "error", common.DATA_GENDER, err)
return res, err
}
res.Content = string(profileInfo)
case common.DATA_YOB:
profileInfo, err = store.ReadEntry(ctx, sessionId, common.DATA_YOB)
if err != nil {
if db.IsNotFound(err) {
res.Content = "Not provided"
break
}
logg.ErrorCtxf(ctx, "Failed to read year of birth(yob) entry with", "key", "error", common.DATA_YOB, err)
return res, err
}
res.Content = string(profileInfo)
case common.DATA_LOCATION:
profileInfo, err = store.ReadEntry(ctx, sessionId, common.DATA_LOCATION)
if err != nil {
if db.IsNotFound(err) {
res.Content = "Not provided"
break
}
logg.ErrorCtxf(ctx, "Failed to read location entry with", "key", "error", common.DATA_LOCATION, err)
return res, err
}
res.Content = string(profileInfo)
case common.DATA_OFFERINGS:
profileInfo, err = store.ReadEntry(ctx, sessionId, common.DATA_OFFERINGS)
if err != nil {
if db.IsNotFound(err) {
res.Content = "Not provided"
break
}
logg.ErrorCtxf(ctx, "Failed to read offerings entry with", "key", "error", common.DATA_OFFERINGS, err)
return res, err
}
res.Content = string(profileInfo)
default:
break
}
return res, nil
}
func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result var res resource.Result
var defaultValue string var defaultValue string

View File

@ -1,5 +1,5 @@
MOUT retry 0 MOUT retry 1
MOUT quit 9 MOUT quit 9
HALT HALT
INCMP _ 0 INCMP _ 1
INCMP quit 9 INCMP quit 9

View File

@ -0,0 +1,2 @@
Current family name: {{.get_current_profile_info}}
Enter family name:

View File

@ -1,5 +1,7 @@
CATCH incorrect_pin flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
CATCH update_familyname flag_allow_update 1 CATCH update_familyname flag_allow_update 1
LOAD get_current_profile_info 0
RELOAD get_current_profile_info
MOUT back 0 MOUT back 0
HALT HALT
LOAD save_familyname 0 LOAD save_familyname 0

View File

@ -0,0 +1,2 @@
Jina la familia la sasa: {{.get_current_profile_info}}
Weka jina la familia

View File

@ -0,0 +1,2 @@
Current name: {{.get_current_profile_info}}
Enter your first names:

View File

@ -1,5 +1,8 @@
CATCH incorrect_pin flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
CATCH update_firstname flag_allow_update 1 CATCH update_firstname flag_allow_update 1
LOAD get_current_profile_info 0
RELOAD get_current_profile_info
MAP get_current_profile_info
MOUT back 0 MOUT back 0
HALT HALT
LOAD save_firstname 0 LOAD save_firstname 0

View File

@ -0,0 +1,2 @@
Jina la kwanza la sasa {{.get_current_profile_info}}
Weka majina yako ya kwanza:

View File

@ -0,0 +1,2 @@
Current location: {{.get_current_profile_info}}
Enter your location:

View File

@ -1,5 +1,7 @@
CATCH incorrect_pin flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
CATCH update_location flag_allow_update 1 CATCH update_location flag_allow_update 1
LOAD get_current_profile_info 0
RELOAD get_current_profile_info
MOUT back 0 MOUT back 0
HALT HALT
LOAD save_location 0 LOAD save_location 0

View File

@ -0,0 +1,2 @@
Eneo la sasa {{.get_current_profile_info}}
Weka eneo:

View File

@ -0,0 +1,2 @@
Current offerings: {{.get_current_profile_info}}
Enter the services or goods you offer:

View File

@ -1,5 +1,7 @@
CATCH incorrect_pin flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
CATCH update_offerings flag_allow_update 1 CATCH update_offerings flag_allow_update 1
LOAD get_current_profile_info 0
RELOAD get_current_profile_info
LOAD save_offerings 0 LOAD save_offerings 0
MOUT back 0 MOUT back 0
HALT HALT

View File

@ -0,0 +1,2 @@
Unachouza kwa sasa: {{.get_current_profile_info}}
Weka unachouza

View File

@ -2,8 +2,8 @@ LOAD reset_account_authorized 16
RELOAD reset_account_authorized RELOAD reset_account_authorized
LOAD reset_allow_update 0 LOAD reset_allow_update 0
RELOAD reset_allow_update RELOAD reset_allow_update
MOUT edit_name 1 MOUT edit_first_name 1
MOUT edit_familyname 2 MOUT edit_family_name 2
MOUT edit_gender 3 MOUT edit_gender 3
MOUT edit_yob 4 MOUT edit_yob 4
MOUT edit_location 5 MOUT edit_location 5
@ -12,10 +12,10 @@ MOUT view 7
MOUT back 0 MOUT back 0
HALT HALT
INCMP my_account 0 INCMP my_account 0
INCMP enter_name 1 INCMP edit_first_name 1
INCMP enter_familyname 2 INCMP edit_family_name 2
INCMP select_gender 3 INCMP select_gender 3
INCMP enter_yob 4 INCMP edit_yob 4
INCMP enter_location 5 INCMP edit_location 5
INCMP enter_offerings 6 INCMP edit_offerings 6
INCMP view_profile 7 INCMP view_profile 7

View File

@ -0,0 +1,2 @@
Current year of birth: {{.get_current_profile_info}}
Enter your year of birth

View File

@ -1,8 +1,12 @@
CATCH incorrect_pin flag_incorrect_pin 1 CATCH incorrect_pin flag_incorrect_pin 1
CATCH update_yob flag_allow_update 1 CATCH update_yob flag_allow_update 1
LOAD get_current_profile_info 0
RELOAD get_current_profile_info
MAP get_current_profile_info
MOUT back 0 MOUT back 0
HALT HALT
LOAD verify_yob 0 LOAD verify_yob 6
RELOAD verify_yob
CATCH incorrect_date_format flag_incorrect_date_format 1 CATCH incorrect_date_format flag_incorrect_date_format 1
LOAD save_yob 0 LOAD save_yob 0
RELOAD save_yob RELOAD save_yob

View File

@ -0,0 +1,2 @@
Mwaka wa sasa wa kuzaliwa {{.get_current_profile_info}}
Weka mwaka wa kuzaliwa

View File

@ -1 +0,0 @@
Enter family name:

View File

@ -1 +0,0 @@
Weka jina la familia

View File

@ -1 +0,0 @@
Enter your location:

View File

@ -1 +0,0 @@
Weka eneo:

View File

@ -1 +0,0 @@
Enter your first names:

View File

@ -1 +0,0 @@
Weka majina yako ya kwanza:

View File

@ -1 +0,0 @@
Enter the services or goods you offer:

View File

@ -1 +0,0 @@
Weka unachouza

View File

@ -1 +0,0 @@
Enter your year of birth

View File

@ -1 +0,0 @@
Weka mwaka wa kuzaliwa

View File

@ -2,5 +2,5 @@ LOAD reset_incorrect_date_format 8
MOUT retry 1 MOUT retry 1
MOUT quit 9 MOUT quit 9
HALT HALT
INCMP enter_yob 1 INCMP _ 1
INCMP quit 9 INCMP quit 9

View File

@ -1 +1,2 @@
Current gender: {{.get_current_profile_info}}
Select gender: Select gender:

View File

@ -1,5 +1,7 @@
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 get_current_profile_info 0
RELOAD get_current_profile_info
MOUT male 1 MOUT male 1
MOUT female 2 MOUT female 2
MOUT unspecified 3 MOUT unspecified 3
@ -9,7 +11,3 @@ INCMP _ 0
INCMP set_male 1 INCMP set_male 1
INCMP set_female 2 INCMP set_female 2
INCMP set_unspecified 3 INCMP set_unspecified 3

View File

@ -1 +1,2 @@
Jinsia ya sasa {{.get_current_profile_info}}
Chagua jinsia Chagua jinsia