rewrite needed, local group connections

This commit is contained in:
2026-03-13 18:55:47 +01:00
parent bb1acfe38f
commit 76fbb8b970
3 changed files with 10 additions and 3 deletions
+1 -2
View File
@@ -22,7 +22,7 @@ func InitDatabase(ctx context.Context) {
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
name VARCHAR(20) UNIQUE NOT NULL, name VARCHAR(20) UNIQUE NOT NULL,
pass_hash VARCHAR(60) 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 ( CREATE TABLE IF NOT EXISTS chat_groups (
id SERIAL PRIMARY KEY, 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) { func CreateChatGroupWithoutMembers(ctx context.Context, group *ChatGroup) (uint32, error) {
if len(group.Name) < 1 { if len(group.Name) < 1 {
return 0, errors.New("group name too short") return 0, errors.New("group name too short")
} }
+5 -1
View File
@@ -41,7 +41,11 @@ func RegisterHandler(response http.ResponseWriter, request *http.Request) {
return 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) http.Error(response, "internal server error", http.StatusInternalServerError)
log.Fatal(err) log.Fatal(err)
return return
+4
View File
@@ -90,6 +90,10 @@ func sendToAllExceptAndCloseIfFails(client *Client, message map[string]any) {
} }
} }
func sendToGroup() {
}
func handleUnauthenticatedMessage(client *Client, msg map[string]any) { func handleUnauthenticatedMessage(client *Client, msg map[string]any) {
token := msg["token"].(string) token := msg["token"].(string)
user, err := GetUserFromToken(token) user, err := GetUserFromToken(token)