Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Add db lite
Acho Arnold10b902f5f59b
diff --git a/api/go.mod b/api/go.modindex 1eef08e4..9cc7ab67 100644--- a/api/go.mod+++ b/api/go.mod@@ -105,7 +105,7 @@ require (github.com/mailru/easyjson v0.7.7 // indirectgithub.com/mattn/go-colorable v0.1.13 // indirectgithub.com/mattn/go-isatty v0.0.20 // indirect- github.com/mattn/go-runewidth v0.0.15 // indirect+ github.com/mattn/go-runewidth v0.0.16 // indirectgithub.com/mitchellh/copystructure v1.2.0 // indirectgithub.com/mitchellh/reflectwalk v1.0.2 // indirectgithub.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect@@ -147,7 +147,7 @@ require (golang.org/x/net v0.30.0 // indirectgolang.org/x/oauth2 v0.23.0 // indirectgolang.org/x/sync v0.8.0 // indirect- golang.org/x/sys v0.26.0 // indirect+ golang.org/x/sys v0.27.0 // indirectgolang.org/x/text v0.19.0 // indirectgolang.org/x/time v0.7.0 // indirectgolang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirectdiff --git a/api/go.sum b/api/go.sumindex 21dea7f1..adbcb331 100644--- a/api/go.sum+++ b/api/go.sum@@ -232,8 +232,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEgithub.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=-github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=-github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=+github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=+github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=@@ -442,8 +442,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=-golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=-golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=+golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=+golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=diff --git a/api/pkg/di/container.go b/api/pkg/di/container.goindex f9808919..5d616648 100644--- a/api/pkg/di/container.go+++ b/api/pkg/di/container.go@@ -248,6 +248,31 @@ func (container *Container) DedicatedDB() (db *gorm.DB) {return container.dedicatedDB}+// DBWithoutMigration creates an instance of gorm.DB if it has not been created already+func (container *Container) DBWithoutMigration() (db *gorm.DB) {+ if container.db != nil {+ return container.db+ }++ container.logger.Debug(fmt.Sprintf("creating %T", db))++ config := &gorm.Config{TranslateError: true}+ if isLocal() {+ config.Logger = container.GormLogger()+ }++ db, err := gorm.Open(postgres.Open(os.Getenv("DATABASE_URL")), config)+ if err != nil {+ container.logger.Fatal(err)+ }+ container.db = db++ if err = db.Use(tracing.NewPlugin()); err != nil {+ container.logger.Fatal(stacktrace.Propagate(err, "cannot use GORM tracing plugin"))+ }+ return container.db+}+// DB creates an instance of gorm.DB if it has not been created alreadyfunc (container *Container) DB() (db *gorm.DB) {if container.db != nil {