Compare commits
No commits in common. "master" and "alias-fqdn" have entirely different histories.
master
...
alias-fqdn
@ -22,8 +22,9 @@ import (
|
||||
|
||||
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -120,8 +121,7 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
accountService := services.New(ctx, menuStorageService, connData)
|
||||
|
||||
accountService := &httpremote.HTTPAccountService{}
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "httpaccountservice: %v\n", err)
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
@ -125,8 +125,7 @@ func main() {
|
||||
|
||||
lhs, err := handlers.NewLocalHandlerService(ctx, pfp, true, dbResource, cfg, rs)
|
||||
lhs.SetDataStore(&userdataStore)
|
||||
|
||||
accountService := services.New(ctx, menuStorageService, connData)
|
||||
accountService := &httpremote.HTTPAccountService{}
|
||||
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
@ -116,8 +116,7 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
accountService := services.New(ctx, menuStorageService, connData)
|
||||
|
||||
accountService := &httpremote.HTTPAccountService{}
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
@ -131,8 +130,6 @@ func main() {
|
||||
}
|
||||
defer stateStore.Close()
|
||||
|
||||
//accountService := services.New(ctx, menuStorageService, connData)
|
||||
|
||||
rp := &httprequest.DefaultRequestParser{}
|
||||
bsh := request.NewBaseRequestHandler(cfg, rs, stateStore, userdataStore, rp, hl)
|
||||
sh := httprequest.NewHTTPRequestHandler(bsh)
|
||||
|
50
cmd/main.go
50
cmd/main.go
@ -13,9 +13,13 @@ import (
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -24,9 +28,37 @@ var (
|
||||
menuSeparator = ": "
|
||||
)
|
||||
|
||||
type devEmitter struct {
|
||||
h *apievent.EventsHandler
|
||||
}
|
||||
|
||||
func (d *devEmitter) emit(ctx context.Context, msg apievent.Msg) error {
|
||||
var err error
|
||||
if msg.Typ == apievent.EventTokenTransferTag {
|
||||
tx, ok := msg.Item.(devremote.Tx)
|
||||
if !ok {
|
||||
return fmt.Errorf("not a valid tx")
|
||||
}
|
||||
logg.InfoCtxf(ctx, "tx emit", "tx", tx)
|
||||
ev := tx.ToTransferEvent()
|
||||
err = d.h.Handle(ctx, apievent.EventTokenTransferTag, &ev)
|
||||
} else if msg.Typ == apievent.EventRegistrationTag {
|
||||
acc, ok := msg.Item.(devremote.Account)
|
||||
if !ok {
|
||||
return fmt.Errorf("not a valid tx")
|
||||
}
|
||||
logg.InfoCtxf(ctx, "account emit", "account", acc)
|
||||
ev := acc.ToRegistrationEvent()
|
||||
err = d.h.Handle(ctx, apievent.EventRegistrationTag, &ev)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func main() {
|
||||
config.LoadConfig()
|
||||
|
||||
var accountService remote.AccountService
|
||||
var fakeDir string
|
||||
var connStr string
|
||||
var size uint
|
||||
var sessionId string
|
||||
@ -39,6 +71,7 @@ func main() {
|
||||
flag.StringVar(&resourceDir, "resourcedir", scriptDir, "resource dir")
|
||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||
flag.StringVar(&connStr, "c", "", "connection string")
|
||||
flag.StringVar(&fakeDir, "fakedir", "", "if valid path, enables fake api with fsdb backend")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.StringVar(&gettextDir, "gettext", "", "use gettext translations from given directory")
|
||||
@ -122,7 +155,20 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
accountService := services.New(ctx, menuStorageService, connData)
|
||||
if fakeDir != "" {
|
||||
svc := devremote.NewDevAccountService()
|
||||
svc = svc.WithFs(ctx, fakeDir)
|
||||
svc = svc.WithAutoVoucher(ctx, "FOO", 42)
|
||||
eu := event.NewEventsUpdater(svc, menuStorageService)
|
||||
emitter := &devEmitter{
|
||||
h: eu.ToEventsHandler(),
|
||||
}
|
||||
svc = svc.WithEmitter(emitter.emit)
|
||||
svc.AddVoucher(ctx, "BAR")
|
||||
accountService = svc
|
||||
} else {
|
||||
accountService = &httpremote.HTTPAccountService{}
|
||||
}
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "get accounts service handler: %v\n", err)
|
||||
|
@ -86,7 +86,7 @@ func main() {
|
||||
cfg := engine.Config{
|
||||
Root: "root",
|
||||
OutputSize: uint32(size),
|
||||
FlagCount: uint32(128),
|
||||
FlagCount: uint32(16),
|
||||
}
|
||||
if stateDebug {
|
||||
cfg.StateDebug = true
|
||||
|
6
go.mod
6
go.mod
@ -3,10 +3,10 @@ module git.grassecon.net/grassrootseconomics/sarafu-vise
|
||||
go 1.23.4
|
||||
|
||||
require (
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250114142051-9645a2af7bef
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d
|
||||
github.com/alecthomas/assert/v2 v2.2.2
|
||||
github.com/gofrs/uuid v4.4.0+incompatible
|
||||
|
12
go.sum
12
go.sum
@ -1,11 +1,11 @@
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739 h1:w7pj1oh7jXrfajahVYU7m7AfHst4C6jNVzDVoaqJ7e8=
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d h1:bPAOVZOX4frSGhfOdcj7kc555f8dc9DmMd2YAyC2AMw=
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05 h1:BenzGx6aDHKDwE23/mWIFD2InYIXyzHroZWV3MF5WUk=
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f h1:FgccQi8vipX6dUt+GRiRDYHMR3UqC+plz73vw7y3fyU=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f/go.mod h1:tbA4whUGMUIDgQVdIW0sxWPuuXOvZRSny5zeku5hX4k=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63 h1:bX7klKZpX+ZZu1LKbtOXDAhV/KK0YwExehiIi0jusAM=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63/go.mod h1:Syw9TZyigPAM7t9FvicOm36iUnidt45f0SxzT2JniQ8=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250114142051-9645a2af7bef h1:ukxNTuI+MF6ic2SkRlc8ZjlnsTR8g6owuHkAvnQNY8A=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250114142051-9645a2af7bef/go.mod h1:BRIbXv0aulFWqR2XV87haWB4oNRlVEu8KyldLQsAroQ=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b h1:6SieNUSEKbkjzquuwazs/lVG56zdEWF10zQQEMRJfMs=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U=
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d h1:q/NO1rEgK3pia32D/tCq5hXfEuJp84COZRwceFvy/MM=
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d/go.mod h1:AH15xABcvaJr1TCGlih3oGSuwWC0E5IdbHQwuu+E1KI=
|
||||
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
||||
|
@ -2187,23 +2187,6 @@ func (h *MenuHandlers) resetIncorrectPINAttempts(ctx context.Context, sessionId
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *MenuHandlers) persistInitialLanguageCode(ctx context.Context, sessionId string, code string) error {
|
||||
store := h.userdataStore
|
||||
_, err := store.ReadEntry(ctx, sessionId, storedb.DATA_INITIAL_LANGUAGE_CODE)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if !db.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_INITIAL_LANGUAGE_CODE, []byte(code))
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "failed to persist initial language code", "key", storedb.DATA_INITIAL_LANGUAGE_CODE, "value", code, "error", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// persistLanguageCode persists the selected ISO 639 language code
|
||||
func (h *MenuHandlers) persistLanguageCode(ctx context.Context, code string) error {
|
||||
store := h.userdataStore
|
||||
@ -2216,5 +2199,5 @@ func (h *MenuHandlers) persistLanguageCode(ctx context.Context, code string) err
|
||||
logg.ErrorCtxf(ctx, "failed to persist language code", "key", storedb.DATA_SELECTED_LANGUAGE_CODE, "value", code, "error", err)
|
||||
return err
|
||||
}
|
||||
return h.persistInitialLanguageCode(ctx, sessionId, code)
|
||||
return nil
|
||||
}
|
||||
|
@ -825,17 +825,6 @@ func TestSetLanguage(t *testing.T) {
|
||||
|
||||
// Assert that the Result FlagSet has the required flags after language switch
|
||||
assert.Equal(t, res, tt.expectedResult, "Result should match expected result")
|
||||
code, err := store.ReadEntry(ctx, sessionId, storedb.DATA_SELECTED_LANGUAGE_CODE)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
assert.Equal(t, string(code), tt.expectedResult.Content)
|
||||
code, err = store.ReadEntry(ctx, sessionId, storedb.DATA_INITIAL_LANGUAGE_CODE)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.Equal(t, string(code), "eng")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
// +build !online
|
||||
|
||||
package services
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"context"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||
)
|
||||
|
||||
type localEmitter struct {
|
||||
h *apievent.EventsHandler
|
||||
}
|
||||
|
||||
func (d *localEmitter) emit(ctx context.Context, msg apievent.Msg) error {
|
||||
var err error
|
||||
if msg.Typ == apievent.EventTokenTransferTag {
|
||||
tx, ok := msg.Item.(devremote.Tx)
|
||||
if !ok {
|
||||
return fmt.Errorf("not a valid tx")
|
||||
}
|
||||
ev := tx.ToTransferEvent()
|
||||
err = d.h.Handle(ctx, apievent.EventTokenTransferTag, &ev)
|
||||
} else if msg.Typ == apievent.EventRegistrationTag {
|
||||
acc, ok := msg.Item.(devremote.Account)
|
||||
if !ok {
|
||||
return fmt.Errorf("not a valid tx")
|
||||
}
|
||||
ev := acc.ToRegistrationEvent()
|
||||
err = d.h.Handle(ctx, apievent.EventRegistrationTag, &ev)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func New(ctx context.Context, storageService storage.StorageService, conn storage.ConnData) remote.AccountService {
|
||||
svc := devremote.NewDevAccountService(ctx, storageService)
|
||||
svc = svc.WithAutoVoucher(ctx, "FOO", 42)
|
||||
eu := event.NewEventsUpdater(svc, storageService)
|
||||
emitter := &localEmitter{
|
||||
h: eu.ToEventsHandler(),
|
||||
}
|
||||
svc = svc.WithEmitter(emitter.emit)
|
||||
svc.AddVoucher(ctx, "BAR")
|
||||
return svc
|
||||
}
|
@ -1 +1 @@
|
||||
Your account is still being created. For more help, please call: 0757628885
|
||||
Your account is still being created.
|
@ -1 +1 @@
|
||||
Akaunti yako bado inatengenezwa. Kwa usaidizi zaidi, piga: 0757628885
|
||||
Akaunti yako bado inatengenezwa
|
@ -1,15 +0,0 @@
|
||||
// +build online
|
||||
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
)
|
||||
|
||||
func New(ctx context.Context, storageService storage.StorageService, conn storage.ConnData) remote.AccountService {
|
||||
return &httpremote.HTTPAccountService{}
|
||||
}
|
@ -44,8 +44,6 @@ func(s *SshKeyStore) AddFromFile(ctx context.Context, fp string, sessionId strin
|
||||
return fmt.Errorf("Failed to parse public key: %v", err)
|
||||
}
|
||||
k := append([]byte{0x01}, pubKey.Marshal()...)
|
||||
s.store.SetLanguage(nil)
|
||||
s.store.SetSession("")
|
||||
s.store.SetPrefix(storage.DATATYPE_EXTEND)
|
||||
logg.Infof("Added key", "sessionId", sessionId, "public key", string(publicBytes))
|
||||
return s.store.Put(ctx, k, []byte(sessionId))
|
||||
@ -53,7 +51,6 @@ func(s *SshKeyStore) AddFromFile(ctx context.Context, fp string, sessionId strin
|
||||
|
||||
func(s *SshKeyStore) Get(ctx context.Context, pubKey ssh.PublicKey) (string, error) {
|
||||
s.store.SetLanguage(nil)
|
||||
s.store.SetSession("")
|
||||
s.store.SetPrefix(storage.DATATYPE_EXTEND)
|
||||
k := append([]byte{0x01}, pubKey.Marshal()...)
|
||||
v, err := s.store.Get(ctx, k)
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.defalsify.org/vise.git/state"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
|
||||
@ -180,8 +180,7 @@ func(s *SshRunner) GetEngine(sessionId string) (engine.Engine, func(), error) {
|
||||
}
|
||||
|
||||
// TODO: clear up why pointer here and by-value other cmds
|
||||
accountService := services.New(ctx, menuStorageService, s.Conn)
|
||||
|
||||
accountService := &httpremote.HTTPAccountService{}
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -59,8 +59,6 @@ const (
|
||||
DATA_INCORRECT_PIN_ATTEMPTS
|
||||
//ISO 639 code for the selected language.
|
||||
DATA_SELECTED_LANGUAGE_CODE
|
||||
//ISO 639 code for the language initially selected.
|
||||
DATA_INITIAL_LANGUAGE_CODE
|
||||
)
|
||||
|
||||
const (
|
||||
|
Loading…
Reference in New Issue
Block a user