mirror of
https://github.com/go-gitea/gitea
synced 2025-02-05 06:57:58 +01:00
29 lines
464 B
Go
29 lines
464 B
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package websocket
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/olahol/melody"
|
|
)
|
|
|
|
type sessionData struct {
|
|
uid int64
|
|
}
|
|
|
|
func getSessionData(s *melody.Session) (*sessionData, error) {
|
|
_data, ok := s.Get("data")
|
|
if !ok {
|
|
return nil, fmt.Errorf("no session data")
|
|
}
|
|
|
|
data, ok := _data.(*sessionData)
|
|
if !ok {
|
|
return nil, fmt.Errorf("invalid session data")
|
|
}
|
|
|
|
return data, nil
|
|
}
|