before rewrite
This commit is contained in:
+13
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user