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
36 lines
884 B
Go
36 lines
884 B
Go
package models
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// ChannelMember represents a user's membership in a channel.
|
|
type ChannelMember struct {
|
|
Base
|
|
|
|
ChannelID string `json:"channelId"`
|
|
UserID string `json:"userId"`
|
|
Modes string `json:"modes"`
|
|
JoinedAt time.Time `json:"joinedAt"`
|
|
Nick string `json:"nick"` // denormalized from users table
|
|
}
|
|
|
|
// User returns the full User for this membership.
|
|
func (cm *ChannelMember) User(ctx context.Context) (*User, error) {
|
|
if ul := cm.GetUserLookup(); ul != nil {
|
|
return ul.GetUserByID(ctx, cm.UserID)
|
|
}
|
|
|
|
return nil, ErrUserLookupNotAvailable
|
|
}
|
|
|
|
// Channel returns the full Channel for this membership.
|
|
func (cm *ChannelMember) Channel(ctx context.Context) (*Channel, error) {
|
|
if cl := cm.GetChannelLookup(); cl != nil {
|
|
return cl.GetChannelByID(ctx, cm.ChannelID)
|
|
}
|
|
|
|
return nil, ErrChannelLookupNotAvailable
|
|
}
|