change user type from int to uuid string
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/render"
|
||||
@@ -110,15 +109,14 @@ func newMessageID() string {
|
||||
}
|
||||
|
||||
func NewMessage(w http.ResponseWriter, r *http.Request) {
|
||||
err := r.ParseMultipartForm(32 << 20)
|
||||
err := r.ParseMultipartForm(64 << 10)
|
||||
if err != nil {
|
||||
http.Error(w, "Unable to parse form", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
userIDStr := r.FormValue("user_id")
|
||||
userID, err := strconv.ParseInt(userIDStr, 10, 64)
|
||||
if err != nil {
|
||||
userID := r.FormValue("user_id")
|
||||
if userID == "" {
|
||||
http.Error(w, "Invalid user ID", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
@@ -150,7 +148,7 @@ type messageKey struct{}
|
||||
|
||||
type Message struct {
|
||||
ID string `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
UserID string `json:"user_id"`
|
||||
Body string `json:"body"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Edited time.Time `json:"edited"`
|
||||
@@ -175,7 +173,7 @@ type MessageResponse struct {
|
||||
func (m MessageResponse) MarshalJSON() ([]byte, error) {
|
||||
type OrderedMessageResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
UserID string `json:"user_id"`
|
||||
Body string `json:"body"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
Edited *string `json:"edited,omitempty"` // Use a pointer to allow null values
|
||||
|
Reference in New Issue
Block a user