tsk-40: Get Contact bug (#46)

Closes #40

Reviewed-on: phoenix/textsender-api#46
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
phoenix
2025-11-29 20:22:31 +00:00
committed by phoenix
parent 1646428016
commit a8dbd693ba
21 changed files with 31 additions and 37 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ func main() {
log.Println("Database reset completed. Exiting.") log.Println("Database reset completed. Exiting.")
return return
} else { } else {
if exists, err := database.TableExists(ctx, db.Pool, "contacts "); err == nil && !exists { if exists, err := database.TableExists(ctx, db.Pool, "contacts"); err == nil && !exists {
fmt.Println("Resetting database") fmt.Println("Resetting database")
err = db.ResetDatabase(ctx) err = db.ResetDatabase(ctx)
if err != nil { if err != nil {
+1 -1
View File
@@ -3,7 +3,7 @@ module git.kundeng.us/phoenix/textsender-api
go 1.25.4 go 1.25.4
require ( require (
git.kundeng.us/phoenix/textsender-models v0.0.9 git.kundeng.us/phoenix/textsender-models v0.0.10
github.com/go-chi/chi/v5 v5.2.3 github.com/go-chi/chi/v5 v5.2.3
github.com/golang-jwt/jwt/v5 v5.3.0 github.com/golang-jwt/jwt/v5 v5.3.0
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
+2
View File
@@ -1,5 +1,7 @@
git.kundeng.us/phoenix/textsender-models v0.0.9 h1:wHEbDLYzMpXQ8OaIf05xFY1V19iTpQogTJEuKInkjEQ= git.kundeng.us/phoenix/textsender-models v0.0.9 h1:wHEbDLYzMpXQ8OaIf05xFY1V19iTpQogTJEuKInkjEQ=
git.kundeng.us/phoenix/textsender-models v0.0.9/go.mod h1:9iPDQJg1Tc6WMNoW5+f8YKmnosMwlWHJ++hmxNLDEe0= git.kundeng.us/phoenix/textsender-models v0.0.9/go.mod h1:9iPDQJg1Tc6WMNoW5+f8YKmnosMwlWHJ++hmxNLDEe0=
git.kundeng.us/phoenix/textsender-models v0.0.10 h1:0AMe/zm4Xte2BcuqqhRP7+42m+4To+rUnHkR2a9eXlI=
git.kundeng.us/phoenix/textsender-models v0.0.10/go.mod h1:9iPDQJg1Tc6WMNoW5+f8YKmnosMwlWHJ++hmxNLDEe0=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+6 -6
View File
@@ -4,10 +4,10 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"git.kundeng.us/phoenix/textsender-models/tx0/contact"
"github.com/google/uuid" "github.com/google/uuid"
"git.kundeng.us/phoenix/textsender-api/internal/store" "git.kundeng.us/phoenix/textsender-api/internal/store"
"git.kundeng.us/phoenix/textsender-models/pkg/contact"
) )
type RequestAddContact struct { type RequestAddContact struct {
@@ -20,11 +20,6 @@ type AddContactResponse struct {
Data []contact.Contact `json:"data"` Data []contact.Contact `json:"data"`
} }
type GetContactResponse struct {
Message string `json:"message"`
Data []contact.Contact `json:"data"`
}
type ContactHandler struct { type ContactHandler struct {
ContactStore store.ContactStore ContactStore store.ContactStore
} }
@@ -88,6 +83,11 @@ func (c *ContactHandler) AddContact(w http.ResponseWriter, r *http.Request) {
RespondWithJSON(w, statusCode, &resp) RespondWithJSON(w, statusCode, &resp)
} }
type GetContactResponse struct {
Message string `json:"message"`
Data []contact.Contact `json:"data"`
}
// GetContact godoc // GetContact godoc
// @Summary Get contact // @Summary Get contact
// @Description Get a contact record to have a recipient to send a text to (requires JWT) // @Description Get a contact record to have a recipient to send a text to (requires JWT)
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"strings" "strings"
"testing" "testing"
"git.kundeng.us/phoenix/textsender-models/pkg/contact" "git.kundeng.us/phoenix/textsender-models/tx0/contact"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
+1 -1
View File
@@ -4,10 +4,10 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"git.kundeng.us/phoenix/textsender-models/tx0/message"
"github.com/google/uuid" "github.com/google/uuid"
"git.kundeng.us/phoenix/textsender-api/internal/store" "git.kundeng.us/phoenix/textsender-api/internal/store"
"git.kundeng.us/phoenix/textsender-models/pkg/message"
) )
type RequestAddMessage struct { type RequestAddMessage struct {
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"strings" "strings"
"testing" "testing"
"git.kundeng.us/phoenix/textsender-models/pkg/message" "git.kundeng.us/phoenix/textsender-models/tx0/message"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
+1 -1
View File
@@ -3,10 +3,10 @@ package handler
import ( import (
"net/http" "net/http"
"git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/google/uuid" "github.com/google/uuid"
"git.kundeng.us/phoenix/textsender-api/internal/store" "git.kundeng.us/phoenix/textsender-api/internal/store"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling"
) )
type RequestScheduledMessageStatus struct { type RequestScheduledMessageStatus struct {
@@ -8,7 +8,7 @@ import (
"testing" "testing"
"time" "time"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling" "git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
+1 -1
View File
@@ -6,10 +6,10 @@ import (
"strings" "strings"
"time" "time"
"git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/google/uuid" "github.com/google/uuid"
"git.kundeng.us/phoenix/textsender-api/internal/store" "git.kundeng.us/phoenix/textsender-api/internal/store"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling"
) )
type RequestAddScheduledMessage struct { type RequestAddScheduledMessage struct {
+1 -1
View File
@@ -4,11 +4,11 @@ import (
"net/http" "net/http"
"strings" "strings"
"git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
"github.com/google/uuid" "github.com/google/uuid"
"git.kundeng.us/phoenix/textsender-api/internal/store" "git.kundeng.us/phoenix/textsender-api/internal/store"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling"
) )
type RequestAddScheduledMessageEvent struct { type RequestAddScheduledMessageEvent struct {
@@ -9,9 +9,9 @@ import (
"testing" "testing"
"time" "time"
"git.kundeng.us/phoenix/textsender-models/pkg/contact" "git.kundeng.us/phoenix/textsender-models/tx0/contact"
"git.kundeng.us/phoenix/textsender-models/pkg/message" "git.kundeng.us/phoenix/textsender-models/tx0/message"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling" "git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"testing" "testing"
"time" "time"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling" "git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
+2 -3
View File
@@ -3,10 +3,9 @@ package services
import ( import (
"time" "time"
txtmodels_token "git.kundeng.us/phoenix/textsender-models/tx0/token"
txtmodels_user "git.kundeng.us/phoenix/textsender-models/tx0/user"
"github.com/golang-jwt/jwt/v5" "github.com/golang-jwt/jwt/v5"
txtmodels_token "git.kundeng.us/phoenix/textsender-models/pkg/token"
txtmodels_user "git.kundeng.us/phoenix/textsender-models/pkg/user"
) )
type JWTService struct { type JWTService struct {
+1 -2
View File
@@ -4,11 +4,10 @@ import (
"context" "context"
"fmt" "fmt"
"git.kundeng.us/phoenix/textsender-models/tx0/contact"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
"git.kundeng.us/phoenix/textsender-models/pkg/contact"
) )
type ContactStore interface { type ContactStore interface {
+1 -2
View File
@@ -4,11 +4,10 @@ import (
"context" "context"
"fmt" "fmt"
"git.kundeng.us/phoenix/textsender-models/tx0/message"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
"git.kundeng.us/phoenix/textsender-models/pkg/message"
) )
type MessageStore interface { type MessageStore interface {
+2 -3
View File
@@ -5,10 +5,9 @@ import (
"errors" "errors"
"sync" "sync"
"git.kundeng.us/phoenix/textsender-models/tx0/contact"
"git.kundeng.us/phoenix/textsender-models/tx0/message"
"github.com/google/uuid" "github.com/google/uuid"
"git.kundeng.us/phoenix/textsender-models/pkg/contact"
"git.kundeng.us/phoenix/textsender-models/pkg/message"
) )
type Key struct { type Key struct {
@@ -6,9 +6,8 @@ import (
"sync" "sync"
"time" "time"
"git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/google/uuid" "github.com/google/uuid"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling"
) )
type ScheduledMessageEventKey struct { type ScheduledMessageEventKey struct {
@@ -5,9 +5,8 @@ import (
"fmt" "fmt"
"sync" "sync"
"git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/google/uuid" "github.com/google/uuid"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling"
) )
type ScheduledMessageKey struct { type ScheduledMessageKey struct {
@@ -4,11 +4,10 @@ import (
"context" "context"
"fmt" "fmt"
"git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling"
) )
type ScheduledMessageEventStore interface { type ScheduledMessageEventStore interface {
+1 -2
View File
@@ -4,11 +4,10 @@ import (
"context" "context"
"fmt" "fmt"
"git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
"git.kundeng.us/phoenix/textsender-models/pkg/message/scheduling"
) )
type ScheduledMessageStore interface { type ScheduledMessageStore interface {