before rewrite

This commit is contained in:
2026-03-15 17:59:22 +01:00
parent c97b21a39e
commit 9a677d7e46
9 changed files with 125 additions and 30 deletions
+13 -2
View File
@@ -68,7 +68,7 @@ func sendAndCloseIfFails(conn *websocket.Conn, message *map[string]any) {
conn.Close(websocket.StatusGoingAway, "Write error")
}
}
func sendToGroup(id uint32, excludedUserId uint32, message *map[string]any) error {
func sendToGroup(id uint64, excludedUserId uint64, message *map[string]any) error {
if _, ok := Groups[id]; !ok {
return errors.New("Group Not Found")
}
@@ -82,12 +82,23 @@ func sendToGroup(id uint32, excludedUserId uint32, message *map[string]any) erro
}
func handleUnauthenticatedMessage(client *Client, msg map[string]any) {
token := msg["token"].(string)
token, ok := msg["token"].(string)
if !ok {
client.conn.Close(websocket.StatusGoingAway, "invalid token")
return
}
user, err := GetUserFromToken(token)
if err != nil {
client.conn.Close(websocket.StatusPolicyViolation, "invalid token")
return
}
groupIds, err := GetUserMemberGroupIds(context.Background(), user.Id)
if err != nil {
client.conn.Close(websocket.StatusInternalError, "internal error")
return
}
user.MemberGroupsId = groupIds
client.User = &user
m := map[string]any{
"authAs": user.Name,