diff --git a/database.go b/database.go index 48965b8..ab58a8f 100644 --- a/database.go +++ b/database.go @@ -22,7 +22,7 @@ func InitDatabase(ctx context.Context) { id SERIAL PRIMARY KEY, name VARCHAR(20) UNIQUE NOT NULL, pass_hash VARCHAR(60) NOT NULL, - color VARCHAR(3) NOT NULL + color VARCHAR(3) DEFAULT NULL, ); CREATE TABLE IF NOT EXISTS chat_groups ( id SERIAL PRIMARY KEY, @@ -108,7 +108,6 @@ func GetUserDataByName(ctx context.Context, name string) (User, error) { } func CreateChatGroupWithoutMembers(ctx context.Context, group *ChatGroup) (uint32, error) { - if len(group.Name) < 1 { return 0, errors.New("group name too short") } diff --git a/http.go b/http.go index ec6f774..af0af2f 100644 --- a/http.go +++ b/http.go @@ -41,7 +41,11 @@ func RegisterHandler(response http.ResponseWriter, request *http.Request) { return } - if _, err := AddNewUser(ctx, &User{username, password, "xxx", 0, false}); err != nil { + if _, err := AddNewUser(ctx, &User{ + Name: username, + Password: password, + IsPasswordHashed: false, + }); err != nil { http.Error(response, "internal server error", http.StatusInternalServerError) log.Fatal(err) return diff --git a/wsServer.go b/wsServer.go index 225ae9b..4a59014 100644 --- a/wsServer.go +++ b/wsServer.go @@ -90,6 +90,10 @@ func sendToAllExceptAndCloseIfFails(client *Client, message map[string]any) { } } +func sendToGroup() { + +} + func handleUnauthenticatedMessage(client *Client, msg map[string]any) { token := msg["token"].(string) user, err := GetUserFromToken(token)