Fix 380 lint violations across all Go source files including wsl_v5, nlreturn, noinlineerr, errcheck, funlen, funcorder, tagliatelle, perfsprint, modernize, revive, gosec, ireturn, mnd, forcetypeassert, cyclop, and others. Key changes: - Split large handler/command functions into smaller methods - Extract scan helpers for database queries - Reorder exported/unexported methods per funcorder - Add sentinel errors in models package - Use camelCase JSON tags per tagliatelle defaults - Add package comments - Fix .gitignore to not exclude cmd/chat-cli directory
27 lines
586 B
Go
27 lines
586 B
Go
package models
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// Session represents a server-held user session.
|
|
type Session struct {
|
|
Base
|
|
|
|
ID string `json:"id"`
|
|
UserID string `json:"userId"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
LastActiveAt time.Time `json:"lastActiveAt"`
|
|
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
|
|
}
|
|
|
|
// User returns the user who owns this session.
|
|
func (s *Session) User(ctx context.Context) (*User, error) {
|
|
if ul := s.GetUserLookup(); ul != nil {
|
|
return ul.GetUserByID(ctx, s.UserID)
|
|
}
|
|
|
|
return nil, ErrUserLookupNotAvailable
|
|
}
|