package channel import ( "time" ) // Status represents the channel status type Status int const ( StatusActive Status = iota StatusArchived StatusDeleted ) // Channel represents a voice channel type Channel struct { ID string Name string Description string IsPublic bool OwnerID string MemberIDs map[string]bool MaxUsers int32 CreatedAt time.Time UpdatedAt time.Time Status Status } // NewChannel creates a new channel func NewChannel(id, name string, ownerID string) *Channel { now := time.Now() return &Channel{ ID: id, Name: name, IsPublic: true, OwnerID: ownerID, MemberIDs: make(map[string]bool), MaxUsers: 0, // unlimited CreatedAt: now, UpdatedAt: now, Status: StatusActive, } } // IsFull checks if channel is at capacity func (c *Channel) IsFull() bool { return c.MaxUsers > 0 && int32(len(c.MemberIDs)) >= c.MaxUsers } // AddMember adds a member to the channel func (c *Channel) AddMember(userID string) { c.MemberIDs[userID] = true c.UpdatedAt = time.Now() } // RemoveMember removes a member from the channel func (c *Channel) RemoveMember(userID string) { delete(c.MemberIDs, userID) c.UpdatedAt = time.Now() } // IsMember checks if user is a member func (c *Channel) IsMember(userID string) bool { return c.MemberIDs[userID] } // GetMembers returns a slice of member IDs func (c *Channel) GetMembers() []string { members := make([]string, 0, len(c.MemberIDs)) for userID := range c.MemberIDs { members = append(members, userID) } return members } // MemberCount returns the number of members func (c *Channel) MemberCount() int { return len(c.MemberIDs) }