state

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrivateExchange is the ID of the exchange that hosts non-public created
	// by users.
	PrivateExchange uint16 = 4
	// PublicExchange is the ID of the exchange that hosts public chat rooms
	// created by the server operator exclusively.
	PublicExchange uint16 = 5
)
View Source
const (
	// DefaultMaxConcurrentSessions is the default maximum number of concurrent
	// sessions allowed when multi-session is enabled.
	DefaultMaxConcurrentSessions = 5
)

Variables

View Source
var (
	ErrChatRoomNotFound = errors.New("chat room not found")
	ErrDupChatRoom      = errors.New("chat room already exists")
)

ErrChatRoomNotFound indicates that a chat room lookup failed.

View Source
var (
	// ErrDupUser indicates that a user already exists.
	ErrDupUser = errors.New("user already exists")
	// ErrNoUser indicates that a user does not exist.
	ErrNoUser = errors.New("user does not exist")
	// ErrNoEmailAddress indicates that a user has not set an email address.
	ErrNoEmailAddress = errors.New("user has no email address")
)
View Source
var (
	ErrAIMHandleInvalidFormat = errors.New("screen name must start with a letter, cannot end with a space, and must contain only letters, numbers, and spaces")
	ErrAIMHandleLength        = errors.New("screen name must be between 3 and 16 characters")
	ErrPasswordInvalid        = errors.New("invalid password length")
	ErrICQUINInvalidFormat    = errors.New("uin must be a number in the range 10000-2147483646")
)
View Source
var (
	ErrKeywordCategoryExists   = errors.New("keyword category already exists")
	ErrKeywordCategoryNotFound = errors.New("keyword category not found")
	ErrBARTItemExists          = errors.New("BART asset already exists")
	ErrBARTItemNotFound        = errors.New("BART asset not found")
	ErrKeywordExists           = errors.New("keyword already exists")
	ErrKeywordInUse            = errors.New("can't delete keyword that is associated with a user")
	ErrKeywordNotFound         = errors.New("keyword not found")
	ErrOfflineInboxFull        = errors.New("offline inbox full")
)
View Source
var (
	// ErrDupAPIKey is returned when attempting to insert a duplicate API key.
	ErrDupAPIKey = errors.New("API key already exists")
	// ErrNoAPIKey is returned when an API key is not found.
	ErrNoAPIKey = errors.New("API key not found")
)
View Source
var (
	// ErrNoWebAPISession is returned when a WebAPI session is not found.
	ErrNoWebAPISession = errors.New("WebAPI session not found")
	// ErrWebAPISessionExpired is returned when a WebAPI session has expired.
	ErrWebAPISessionExpired = errors.New("WebAPI session expired")
)
View Source
var ErrMaxConcurrentSessionsReached = errors.New("maximum number of concurrent sessions reached")

ErrMaxConcurrentSessionsReached is returned when attempting to add a new session instance but the maximum number of concurrent sessions has been reached.

Functions

This section is empty.

Types

type AIMNameAndAddr

type AIMNameAndAddr struct {
	// FirstName is the user's first name.
	FirstName string
	// LastName is the user's last name.
	LastName string
	// MiddleName is the user's middle name.
	MiddleName string
	// MaidenName is the user's maiden name.
	MaidenName string
	// Country is the user's country of residence.
	Country string
	// State is the user's state or region of residence.
	State string
	// City is the user's city of residence.
	City string
	// NickName is the user's chosen nickname.
	NickName string
	// ZIPCode is the user's postal or ZIP code.
	ZIPCode string
	// Address is the user's street address.
	Address string
}

AIMNameAndAddr holds name and address AIM directory information.

type APIAnalytics

type APIAnalytics struct {
	// contains filtered or unexported fields
}

APIAnalytics provides analytics tracking for the Web API.

func NewAPIAnalytics

func NewAPIAnalytics(db *sql.DB, logger *slog.Logger) *APIAnalytics

NewAPIAnalytics creates a new API analytics instance.

func (*APIAnalytics) CheckQuota

func (a *APIAnalytics) CheckQuota(ctx context.Context, devID string) (bool, *APIQuota, error)

CheckQuota checks if a developer has exceeded their usage quota.

func (*APIAnalytics) Close

func (a *APIAnalytics) Close()

Close stops the analytics processor.

func (*APIAnalytics) GetTopEndpoints

func (a *APIAnalytics) GetTopEndpoints(ctx context.Context, devID string, limit int) ([]struct {
	Endpoint string `json:"endpoint"`
	Count    int    `json:"count"`
}, error)

GetTopEndpoints retrieves the most used endpoints for a developer.

func (*APIAnalytics) GetUsageStats

func (a *APIAnalytics) GetUsageStats(ctx context.Context, devID string, periodType string, startTime, endTime time.Time) ([]APIUsageStats, error)

GetUsageStats retrieves aggregated usage statistics for a developer.

func (*APIAnalytics) IncrementQuotaUsage

func (a *APIAnalytics) IncrementQuotaUsage(ctx context.Context, devID string) error

IncrementQuotaUsage increments the usage counters for a developer.

func (*APIAnalytics) LogHTTPRequest

func (a *APIAnalytics) LogHTTPRequest(ctx context.Context, r *http.Request, statusCode int, responseTime time.Duration, responseSize int, errorMsg string)

LogHTTPRequest logs an HTTP request with timing information.

func (*APIAnalytics) LogRequest

func (a *APIAnalytics) LogRequest(ctx context.Context, log APIUsageLog)

LogRequest logs an API request asynchronously.

type APIQuota

type APIQuota struct {
	DevID            string    `json:"dev_id"`
	DailyLimit       int       `json:"daily_limit"`
	MonthlyLimit     int       `json:"monthly_limit"`
	DailyUsed        int       `json:"daily_used"`
	MonthlyUsed      int       `json:"monthly_used"`
	LastResetDaily   time.Time `json:"last_reset_daily"`
	LastResetMonthly time.Time `json:"last_reset_monthly"`
	OverageAllowed   bool      `json:"overage_allowed"`
}

APIQuota represents API usage quotas for a developer.

type APIUsageLog

type APIUsageLog struct {
	ID             int64     `json:"id"`
	DevID          string    `json:"dev_id"`
	Endpoint       string    `json:"endpoint"`
	Method         string    `json:"method"`
	Timestamp      time.Time `json:"timestamp"`
	ResponseTimeMs int       `json:"response_time_ms"`
	StatusCode     int       `json:"status_code"`
	IPAddress      string    `json:"ip_address"`
	UserAgent      string    `json:"user_agent"`
	ScreenName     string    `json:"screen_name,omitempty"`
	ErrorMessage   string    `json:"error_message,omitempty"`
	RequestSize    int       `json:"request_size"`
	ResponseSize   int       `json:"response_size"`
}

APIUsageLog represents a single API request log entry.

type APIUsageStats

type APIUsageStats struct {
	DevID              string    `json:"dev_id"`
	Endpoint           string    `json:"endpoint"`
	PeriodType         string    `json:"period_type"`
	PeriodStart        time.Time `json:"period_start"`
	RequestCount       int       `json:"request_count"`
	ErrorCount         int       `json:"error_count"`
	TotalResponseTime  int       `json:"total_response_time_ms"`
	AvgResponseTime    int       `json:"avg_response_time_ms"`
	TotalRequestBytes  int64     `json:"total_request_bytes"`
	TotalResponseBytes int64     `json:"total_response_bytes"`
	UniqueUsers        int       `json:"unique_users"`
}

APIUsageStats represents aggregated API usage statistics.

type BARTItem

type BARTItem struct {
	Hash string
	Type uint16
}

BARTItem represents a BART asset with its hash and type.

type BuddyFeed

type BuddyFeed struct {
	ID          int64     `json:"id"`
	ScreenName  string    `json:"screenName"`
	FeedType    string    `json:"feedType"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Link        string    `json:"link"`
	PublishedAt time.Time `json:"publishedAt"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
	IsActive    bool      `json:"isActive"`
}

BuddyFeed represents a user's feed configuration.

type BuddyFeedItem

type BuddyFeedItem struct {
	ID          int64     `json:"id"`
	FeedID      int64     `json:"feedId"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Link        string    `json:"link"`
	GUID        string    `json:"guid"`
	Author      string    `json:"author"`
	Categories  []string  `json:"categories"`
	PublishedAt time.Time `json:"publishedAt"`
	CreatedAt   time.Time `json:"createdAt"`
}

BuddyFeedItem represents an individual feed entry.

type BuddyFeedManager

type BuddyFeedManager struct {
	// contains filtered or unexported fields
}

BuddyFeedManager manages buddy feed operations.

func NewBuddyFeedManager

func NewBuddyFeedManager(db *sql.DB, logger *slog.Logger) *BuddyFeedManager

NewBuddyFeedManager creates a new buddy feed manager.

func (*BuddyFeedManager) AddFeedItem

func (m *BuddyFeedManager) AddFeedItem(ctx context.Context, feedID int64, item BuddyFeedItem) (*BuddyFeedItem, error)

AddFeedItem adds a new item to a feed.

func (*BuddyFeedManager) CreateFeed

func (m *BuddyFeedManager) CreateFeed(ctx context.Context, feed BuddyFeed) (*BuddyFeed, error)

CreateFeed creates a new buddy feed.

func (*BuddyFeedManager) GetBuddyListFeedItems

func (m *BuddyFeedManager) GetBuddyListFeedItems(ctx context.Context, buddies []IdentScreenName, limit int) ([]BuddyFeedItem, error)

GetBuddyListFeedItems retrieves aggregated feed items for a user's buddy list.

func (*BuddyFeedManager) GetFeedItems

func (m *BuddyFeedManager) GetFeedItems(ctx context.Context, feedID int64, limit int) ([]BuddyFeedItem, error)

GetFeedItems retrieves items for a specific feed.

func (*BuddyFeedManager) GetOrCreateFeedForUser

func (m *BuddyFeedManager) GetOrCreateFeedForUser(ctx context.Context, screenName string, feedType string) (int64, error)

GetOrCreateFeedForUser gets an existing feed or creates a new one for a user.

func (*BuddyFeedManager) GetUserFeed

func (m *BuddyFeedManager) GetUserFeed(ctx context.Context, screenName string) (*BuddyFeed, error)

GetUserFeed retrieves the feed configuration for a specific user.

func (*BuddyFeedManager) GetUserFeedItems

func (m *BuddyFeedManager) GetUserFeedItems(ctx context.Context, screenName string, limit int) ([]BuddyFeedItem, error)

GetUserFeedItems retrieves feed items for a specific user.

type BuddyFeedSubscription

type BuddyFeedSubscription struct {
	ID                   int64      `json:"id"`
	SubscriberScreenName string     `json:"subscriberScreenName"`
	FeedID               int64      `json:"feedId"`
	SubscribedAt         time.Time  `json:"subscribedAt"`
	LastCheckedAt        *time.Time `json:"lastCheckedAt"`
}

BuddyFeedSubscription represents a feed subscription.

type Category

type Category struct {
	// ID is the category ID
	ID uint8
	// Name is the category name
	Name string `oscar:"len_prefix=uint16"`
}

Category represents an AIM directory category.

type ChatEventData

type ChatEventData struct {
	ChatSID   string        `json:"chatsid"`
	EventType ChatEventType `json:"eventType"`
	EventData interface{}   `json:"eventData"`
}

ChatEventData represents data for a chat event

type ChatEventType

type ChatEventType string

ChatEventType represents the type of chat event

const (
	ChatEventUserInRoom  ChatEventType = "userInRoom"
	ChatEventUserEntered ChatEventType = "userEntered"
	ChatEventUserLeft    ChatEventType = "userLeft"
	ChatEventMessage     ChatEventType = "message"
	ChatEventTyping      ChatEventType = "typing"
	ChatEventClosed      ChatEventType = "closed"
)

type ChatMessage

type ChatMessage struct {
	ID            int64
	RoomID        string
	ScreenName    string
	Message       string
	WhisperTarget string
	Timestamp     int64
}

ChatMessage represents a message sent in a chat room

type ChatMessageEventData

type ChatMessageEventData struct {
	ScreenName    string `json:"screenName"`
	Message       string `json:"message"`
	Timestamp     int64  `json:"timestamp"`
	WhisperTarget string `json:"whisperTarget,omitempty"`
}

ChatMessageEventData represents chat message event data

type ChatParticipant

type ChatParticipant struct {
	RoomID          string
	ScreenName      string
	ChatSID         string
	JoinedAt        int64
	TypingStatus    string
	TypingUpdatedAt *int64
}

ChatParticipant represents a participant in a chat room

type ChatParticipantList

type ChatParticipantList struct {
	Participants []string `json:"participants"`
}

ChatParticipantList represents a list of participants in the room

type ChatRoom

type ChatRoom struct {
	// contains filtered or unexported fields
}

ChatRoom represents of a chat room.

func NewChatRoom

func NewChatRoom(name string, creator IdentScreenName, exchange uint16) ChatRoom

NewChatRoom creates a new ChatRoom instance.

func (ChatRoom) Cookie

func (c ChatRoom) Cookie() string

Cookie returns the chat room unique identifier.

func (ChatRoom) CreateTime

func (c ChatRoom) CreateTime() time.Time

CreateTime returns when the chat room was inserted in the database.

func (ChatRoom) Creator

func (c ChatRoom) Creator() IdentScreenName

Creator returns the screen name of the user who created the chat room.

func (ChatRoom) DetailLevel

func (c ChatRoom) DetailLevel() uint8

DetailLevel returns the detail level of the chat room (whatever that means).

func (ChatRoom) Exchange

func (c ChatRoom) Exchange() uint16

Exchange returns which exchange the chat room belongs to.

func (ChatRoom) InstanceNumber

func (c ChatRoom) InstanceNumber() uint16

InstanceNumber returns which instance chatroom exists in. Overflow chat rooms do not exist yet, so all chats happen in the same instance.

func (ChatRoom) Name

func (c ChatRoom) Name() string

Name returns the chat room name.

func (ChatRoom) TLVList

func (c ChatRoom) TLVList() []wire.TLV

TLVList returns a TLV list of chat room metadata.

func (ChatRoom) URL

func (c ChatRoom) URL() *url.URL

URL creates a URL that can be used to join a chat room.

type ChatRoomType

type ChatRoomType string

ChatRoomType represents the type of chat room

const (
	ChatRoomTypeUserCreated ChatRoomType = "userCreated"
)

type ChatSession

type ChatSession struct {
	ChatSID    string
	AIMSid     string
	RoomID     string
	ScreenName string
	InstanceID int
	JoinedAt   int64
	LeftAt     *int64
}

ChatSession represents a user's session in a chat room

type ChatTypingEventData

type ChatTypingEventData struct {
	ScreenName   string `json:"screenName"`
	TypingStatus string `json:"typingStatus"`
}

ChatTypingEventData represents typing status event data

type ChatUserEventData

type ChatUserEventData struct {
	ScreenName string `json:"screenName"`
	Timestamp  int64  `json:"timestamp"`
}

ChatUserEventData represents user join/leave event data

type DisplayScreenName

type DisplayScreenName string

DisplayScreenName type represents the screen name in the user-defined format. This includes the original casing and spacing as defined by the user.

func (DisplayScreenName) IdentScreenName

func (s DisplayScreenName) IdentScreenName() IdentScreenName

IdentScreenName converts the DisplayScreenName to an IdentScreenName by applying the normalization process defined in NewIdentScreenName.

func (DisplayScreenName) IsUIN

func (s DisplayScreenName) IsUIN() bool

IsUIN indicates whether the screen name is an ICQ UIN.

func (DisplayScreenName) String

func (s DisplayScreenName) String() string

String returns the original display string of the screen name, preserving the user-defined casing and spaces.

func (DisplayScreenName) ValidateAIMHandle

func (s DisplayScreenName) ValidateAIMHandle() error

ValidateAIMHandle returns an error if the instance is not a valid AIM screen name. Possible errors:

  • ErrAIMHandleLength: if the screen name has less than 3 non-space characters or more than 16 characters (including spaces).
  • ErrAIMHandleInvalidFormat: if the screen name does not start with a letter, ends with a space, or contains invalid characters

func (DisplayScreenName) ValidateUIN

func (s DisplayScreenName) ValidateUIN() error

ValidateUIN returns an error if the instance is not a valid ICQ UIN. Possible errors:

  • ErrICQUINInvalidFormat: if the UIN is not a number or is not in the valid range

type HMACCookieBaker

type HMACCookieBaker struct {
	// contains filtered or unexported fields
}

func NewHMACCookieBaker

func NewHMACCookieBaker() (HMACCookieBaker, error)

func (HMACCookieBaker) Crack

func (c HMACCookieBaker) Crack(data []byte) ([]byte, error)

func (HMACCookieBaker) Issue

func (c HMACCookieBaker) Issue(data []byte) ([]byte, error)

type ICQAffiliations

type ICQAffiliations struct {
	// PastCode1 is the code representing the user's first past affiliation.
	PastCode1 uint16
	// PastKeyword1 is the keyword associated with the user's first past affiliation.
	PastKeyword1 string
	// PastCode2 is the code representing the user's second past affiliation.
	PastCode2 uint16
	// PastKeyword2 is the keyword associated with the user's second past affiliation.
	PastKeyword2 string
	// PastCode3 is the code representing the user's third past affiliation.
	PastCode3 uint16
	// PastKeyword3 is the keyword associated with the user's third past affiliation.
	PastKeyword3 string
	// CurrentCode1 is the code representing the user's current first affiliation.
	CurrentCode1 uint16
	// CurrentKeyword1 is the keyword associated with the user's current first affiliation.
	CurrentKeyword1 string
	// CurrentCode2 is the code representing the user's current second affiliation.
	CurrentCode2 uint16
	// CurrentKeyword2 is the keyword associated with the user's current second affiliation.
	CurrentKeyword2 string
	// CurrentCode3 is the code representing the user's current third affiliation.
	CurrentCode3 uint16
	// CurrentKeyword3 is the keyword associated with the user's current third affiliation.
	CurrentKeyword3 string
}

ICQAffiliations contains information about the user's affiliations, both past and present.

type ICQBasicInfo

type ICQBasicInfo struct {
	// Address is the user's residential address.
	Address string
	// CellPhone is the user's mobile phone number.
	CellPhone string
	// City is the city where the user resides.
	City string
	// CountryCode is the code representing the user's country of residence.
	CountryCode uint16
	// EmailAddress is the user's primary email address.
	EmailAddress string
	// Fax is the user's fax number.
	Fax string
	// FirstName is the user's first name.
	FirstName string
	// GMTOffset is the user's time zone offset from GMT.
	GMTOffset uint8
	// LastName is the user's last name.
	LastName string
	// Nickname is the user's nickname or preferred name.
	Nickname string
	// Phone is the user's landline phone number.
	Phone string
	// PublishEmail indicates whether the user's email address is public.
	PublishEmail bool
	// State is the state or region where the user resides.
	State string
	// ZIPCode is the user's postal code.
	ZIPCode string
}

ICQBasicInfo holds basic information about an ICQ user, including their name, contact details, and location.

type ICQInterests

type ICQInterests struct {
	// Code1 is the code representing the user's first interest.
	Code1 uint16
	// Keyword1 is the keyword associated with the user's first interest.
	Keyword1 string
	// Code2 is the code representing the user's second interest.
	Code2 uint16
	// Keyword2 is the keyword associated with the user's second interest.
	Keyword2 string
	// Code3 is the code representing the user's third interest.
	Code3 uint16
	// Keyword3 is the keyword associated with the user's third interest.
	Keyword3 string
	// Code4 is the code representing the user's fourth interest.
	Code4 uint16
	// Keyword4 is the keyword associated with the user's fourth interest.
	Keyword4 string
}

ICQInterests holds information about the user's interests, categorized by interest code and associated keyword.

type ICQMoreInfo

type ICQMoreInfo struct {
	// Gender is the user's gender, represented by a code.
	Gender uint16
	// HomePageAddr is the URL of the user's personal homepage.
	HomePageAddr string
	// BirthYear is the user's birth year.
	BirthYear uint16
	// BirthMonth is the user's birth month.
	BirthMonth uint8
	// BirthDay is the user's birth day.
	BirthDay uint8
	// Lang1 is the code for the user's primary language.
	Lang1 uint8
	// Lang2 is the code for the user's secondary language.
	Lang2 uint8
	// Lang3 is the code for the user's tertiary language.
	Lang3 uint8
}

ICQMoreInfo contains additional information about the user, such as demographic and language preferences.

type ICQPermissions

type ICQPermissions struct {
	// AuthRequired indicates where users must ask this permission to add them
	// to their contact list.
	AuthRequired bool
}

ICQPermissions specifies the privacy settings of an ICQ user.

type ICQUserNotes

type ICQUserNotes struct {
	// Notes are the personal notes or additional information the user has
	// entered in their profile.
	Notes string
}

ICQUserNotes contains personal notes or additional information added by the user.

type ICQWorkInfo

type ICQWorkInfo struct {
	// Address is the address of the user's workplace.
	Address string
	// City is the city where the user's workplace is located.
	City string
	// Company is the name of the user's employer or company.
	Company string
	// CountryCode is the code representing the country where the user's
	// workplace is located.
	CountryCode uint16
	// Department is the name of the department within the user's company.
	Department string
	// Fax is the fax number for the user's workplace.
	Fax string
	// OccupationCode is the code representing the user's occupation.
	OccupationCode uint16
	// Phone is the phone number for the user's workplace.
	Phone string
	// Position is the user's job title or position within the company.
	Position string
	// State is the state or region where the user's workplace is located.
	State string
	// WebPage is the URL of the user's company's website.
	WebPage string
	// ZIPCode is the postal code for the user's workplace.
	ZIPCode string
}

ICQWorkInfo contains information about the user's professional life, including their workplace and job title.

type IdentScreenName

type IdentScreenName struct {
	// contains filtered or unexported fields
}

IdentScreenName struct stores the normalized version of a user's screen name. This format is used for uniformity in storage and comparison by removing spaces and converting all characters to lowercase.

func NewIdentScreenName

func NewIdentScreenName(screenName string) IdentScreenName

NewIdentScreenName creates a new IdentScreenName.

func (IdentScreenName) String

func (i IdentScreenName) String() string

String returns the string representation of the IdentScreenName.

func (IdentScreenName) UIN

func (i IdentScreenName) UIN() uint32

UIN returns a numeric UIN representation of the IdentScreenName.

type InMemoryChatSessionManager

type InMemoryChatSessionManager struct {
	// contains filtered or unexported fields
}

InMemoryChatSessionManager manages chat sessions for multiple chat rooms stored in memory. It provides thread-safe operations to add, remove, and manipulate sessions as well as relay messages to participants.

func NewInMemoryChatSessionManager

func NewInMemoryChatSessionManager(logger *slog.Logger) *InMemoryChatSessionManager

NewInMemoryChatSessionManager creates a new instance of InMemoryChatSessionManager.

func (*InMemoryChatSessionManager) AddSession

func (s *InMemoryChatSessionManager) AddSession(ctx context.Context, chatCookie string, screenName DisplayScreenName) (*SessionInstance, error)

AddSession adds a user to a chat room. If screenName already exists, the old session is replaced by a new one.

func (*InMemoryChatSessionManager) AllSessions

func (s *InMemoryChatSessionManager) AllSessions(cookie string) []*Session

AllSessions returns all chat room participants. Returns ErrChatRoomNotFound if the room does not exist.

func (*InMemoryChatSessionManager) RelayToAllExcept

func (s *InMemoryChatSessionManager) RelayToAllExcept(ctx context.Context, cookie string, except IdentScreenName, msg wire.SNACMessage)

RelayToAllExcept sends a message to all chat room participants except for the participant with a particular screen name. Returns ErrChatRoomNotFound if the room does not exist for cookie.

func (*InMemoryChatSessionManager) RelayToScreenName

func (s *InMemoryChatSessionManager) RelayToScreenName(ctx context.Context, cookie string, recipient IdentScreenName, msg wire.SNACMessage)

RelayToScreenName sends a message to a chat room user. Returns ErrChatRoomNotFound if the room does not exist for cookie.

func (*InMemoryChatSessionManager) RemoveSession

func (s *InMemoryChatSessionManager) RemoveSession(instance *SessionInstance)

RemoveSession removes a user session from a chat room. It panics if you attempt to remove the session twice.

func (*InMemoryChatSessionManager) RemoveUserFromAllChats

func (s *InMemoryChatSessionManager) RemoveUserFromAllChats(user IdentScreenName)

RemoveUserFromAllChats removes a user's session from all chat rooms.

type InMemorySessionManager

type InMemorySessionManager struct {
	// contains filtered or unexported fields
}

InMemorySessionManager handles the lifecycle of a user session and provides synchronized message relay between sessions in the session pool. An InMemorySessionManager is safe for concurrent use by multiple goroutines.

func NewInMemorySessionManager

func NewInMemorySessionManager(logger *slog.Logger) *InMemorySessionManager

NewInMemorySessionManager creates a new instance of InMemorySessionManager.

func (*InMemorySessionManager) AddSession

func (s *InMemorySessionManager) AddSession(ctx context.Context, screenName DisplayScreenName, doMultiSess bool) (*SessionInstance, error)

func (*InMemorySessionManager) AllSessions

func (s *InMemorySessionManager) AllSessions() []*Session

AllSessions returns all sessions in the session pool.

func (*InMemorySessionManager) Empty

func (s *InMemorySessionManager) Empty() bool

Empty returns true if the session pool contains 0 sessions.

func (*InMemorySessionManager) RelayToAll

func (s *InMemorySessionManager) RelayToAll(ctx context.Context, msg wire.SNACMessage)

RelayToAll relays a message to all sessions in the session pool.

func (*InMemorySessionManager) RelayToOtherInstances

func (s *InMemorySessionManager) RelayToOtherInstances(ctx context.Context, instance *SessionInstance, msg wire.SNACMessage)

func (*InMemorySessionManager) RelayToScreenName

func (s *InMemorySessionManager) RelayToScreenName(ctx context.Context, screenName IdentScreenName, msg wire.SNACMessage)

RelayToScreenName relays a message to a session with a matching screen name.

func (*InMemorySessionManager) RelayToScreenNameActiveOnly

func (s *InMemorySessionManager) RelayToScreenNameActiveOnly(ctx context.Context, screenName IdentScreenName, msg wire.SNACMessage)

func (*InMemorySessionManager) RelayToScreenNames

func (s *InMemorySessionManager) RelayToScreenNames(ctx context.Context, screenNames []IdentScreenName, msg wire.SNACMessage)

RelayToScreenNames relays a message to sessions with matching screenNames.

func (*InMemorySessionManager) RelayToSelf

func (s *InMemorySessionManager) RelayToSelf(ctx context.Context, instance *SessionInstance, msg wire.SNACMessage)

func (*InMemorySessionManager) RemoveSession

func (s *InMemorySessionManager) RemoveSession(instance *SessionInstance)

RemoveSession takes a session out of the session pool.

func (*InMemorySessionManager) RetrieveSession

func (s *InMemorySessionManager) RetrieveSession(screenName IdentScreenName) *Session

RetrieveSession finds a session with a matching screen name. Returns nil if session is not found or if there are no active instances with complete signon.

type Keyword

type Keyword struct {
	// ID is the keyword ID
	ID uint8
	// Name is the keyword name
	Name string `oscar:"len_prefix=uint16"`
}

Keyword represents an AIM directory keyword.

type OSCARBridgeSession

type OSCARBridgeSession struct {
	WebSessionID  string    // WebAPI session identifier
	OSCARCookie   []byte    // OSCAR authentication cookie
	BOSHost       string    // BOS server hostname
	BOSPort       int       // BOS server port
	UseSSL        bool      // Whether to use SSL connection
	ScreenName    string    // Screen name associated with the session
	ClientName    string    // Client application name
	ClientVersion string    // Client application version
	CreatedAt     time.Time // Bridge creation timestamp
	LastAccessed  time.Time // Last access timestamp
}

OSCARBridgeSession represents a bridge between WebAPI and OSCAR sessions.

type OSCARBridgeStore

type OSCARBridgeStore struct {
	// contains filtered or unexported fields
}

OSCARBridgeStore manages the persistence of OSCAR bridge sessions in the database. It provides methods to store, retrieve, and manage the mapping between WebAPI sessions and OSCAR authentication cookies.

func (*OSCARBridgeStore) CleanupExpiredSessions

func (s *OSCARBridgeStore) CleanupExpiredSessions(ctx context.Context, maxAge time.Duration) (int, error)

CleanupExpiredSessions removes bridge sessions that haven't been accessed recently.

func (*OSCARBridgeStore) DeleteBridgeSession

func (s *OSCARBridgeStore) DeleteBridgeSession(ctx context.Context, webSessionID string) error

DeleteBridgeSession removes a bridge session.

func (*OSCARBridgeStore) GetAllBridgeSessions

func (s *OSCARBridgeStore) GetAllBridgeSessions(ctx context.Context) ([]*OSCARBridgeSession, error)

GetAllBridgeSessions returns all active bridge sessions (for monitoring/admin).

func (*OSCARBridgeStore) GetBridgeSession

func (s *OSCARBridgeStore) GetBridgeSession(ctx context.Context, webSessionID string) (*OSCARBridgeSession, error)

GetBridgeSession retrieves bridge session details by WebAPI session ID.

func (*OSCARBridgeStore) GetBridgeSessionByScreenName

func (s *OSCARBridgeStore) GetBridgeSessionByScreenName(ctx context.Context, screenName string) ([]*OSCARBridgeSession, error)

GetBridgeSessionByScreenName retrieves bridge sessions by screen name.

func (*OSCARBridgeStore) GetStatistics

func (s *OSCARBridgeStore) GetStatistics(ctx context.Context) (map[string]interface{}, error)

GetStatistics returns statistics about bridge sessions.

func (*OSCARBridgeStore) SaveBridgeSession

func (s *OSCARBridgeStore) SaveBridgeSession(ctx context.Context, webSessionID string,
	oscarCookie []byte, bosHost string, bosPort int) error

SaveBridgeSession stores the mapping between WebAPI and OSCAR sessions.

func (*OSCARBridgeStore) SaveBridgeSessionWithDetails

func (s *OSCARBridgeStore) SaveBridgeSessionWithDetails(ctx context.Context, session *OSCARBridgeSession) error

SaveBridgeSessionWithDetails stores a complete bridge session with all details.

func (*OSCARBridgeStore) ValidateOSCARCookie

func (s *OSCARBridgeStore) ValidateOSCARCookie(ctx context.Context, cookie []byte) (*OSCARBridgeSession, error)

ValidateOSCARCookie checks if an OSCAR cookie exists in the bridge store. This can be used to validate incoming OSCAR connections.

type OfflineMessage

type OfflineMessage struct {
	Sender    IdentScreenName
	Recipient IdentScreenName
	Message   wire.SNAC_0x04_0x06_ICBMChannelMsgToHost
	Sent      time.Time
}

type RateClassState

type RateClassState struct {
	// static rate limit configuration for this class
	wire.RateClass
	// CurrentLevel is the current exponential moving average for this rate
	// class.
	CurrentLevel int32
	// LastTime represents the last time a SNAC message was sent for this rate
	// class.
	LastTime time.Time
	// CurrentStatus is the last recorded rate limit status for this rate class.
	CurrentStatus wire.RateLimitStatus
	// Subscribed indicates whether the user wants to receive rate limit
	// parameter updates for this rate class.
	Subscribed bool
	// LimitedNow indicates whether the user is currently rate limited for this
	// rate class; the user is blocked from sending SNACs in this rate class
	// until the clear threshold is met.
	LimitedNow bool
}

RateClassState tracks the rate limiting state for a specific rate class within a user's session.

It embeds the static wire.RateClass configuration and maintains dynamic, per-session state used to evaluate rate limits in real time.

type Relationship

type Relationship struct {
	// User is the screen name of the user with whom you have a relationship.
	User IdentScreenName
	// BlocksYou indicates whether user blocks you. This is true when user has
	// the following permit/deny modes set:
	// 	- DenyAll
	// 	- PermitSome (and you are not on permit list)
	// 	- DenySome (and you are on deny list)
	// 	- PermitOnList (and you are not on their buddy list)
	BlocksYou bool
	// YouBlock indicates whether you block user. This is true when user has
	// the following permit/deny modes set:
	// 	- DenyAll
	// 	- PermitSome (and they are not on your permit list)
	// 	- DenySome (and they are on your deny list)
	// 	- PermitOnList (and they are not on your buddy list)
	YouBlock bool
	// IsOnTheirList indicates whether you are on user's buddy list.
	IsOnTheirList bool
	// IsOnYourList indicates whether this user is on your buddy list.
	IsOnYourList bool
}

Relationship represents the relationship between two users. Users A and B are related if:

  • A has user B on their buddy list, or vice versa
  • A has user B on their deny list, or vice versa
  • A has user B on their permit list, or vice versa

type SQLiteUserStore

type SQLiteUserStore struct {
	// contains filtered or unexported fields
}

SQLiteUserStore stores user feedbag (buddy list), profile, and authentication credentials information in a SQLite database.

func NewSQLiteUserStore

func NewSQLiteUserStore(dbFilePath string) (*SQLiteUserStore, error)

NewSQLiteUserStore creates a new instance of SQLiteUserStore. If the database does not already exist, a new one is created with the required schema.

func (SQLiteUserStore) AddBuddy

func (SQLiteUserStore) AllChatRooms

func (f SQLiteUserStore) AllChatRooms(ctx context.Context, exchange uint16) ([]ChatRoom, error)

func (SQLiteUserStore) AllRelationships

func (f SQLiteUserStore) AllRelationships(ctx context.Context, me IdentScreenName, filter []IdentScreenName) ([]Relationship, error)

AllRelationships retrieves the relationships between the specified user (`me`) and other users.

A relationship is defined by the Relationship type, which describes the nature of the connection between users.

This function only includes users who have activated their buddy list through a call to SQLiteUserStore.RegisterBuddyList. The results can be optionally filtered to include only specific users by providing their identifiers in the `filter` parameter.

func (SQLiteUserStore) AllUsers

func (f SQLiteUserStore) AllUsers(ctx context.Context) ([]User, error)

func (*SQLiteUserStore) AuthenticateUser

func (u *SQLiteUserStore) AuthenticateUser(ctx context.Context, username, password string) (*User, error)

AuthenticateUser verifies username and password. This implementation uses the existing user store for authentication.

func (SQLiteUserStore) BARTItem

func (f SQLiteUserStore) BARTItem(ctx context.Context, hash []byte) ([]byte, error)

func (SQLiteUserStore) BuddyIconMetadata

func (f SQLiteUserStore) BuddyIconMetadata(ctx context.Context, screenName IdentScreenName) (*wire.BARTID, error)

func (SQLiteUserStore) Categories

func (f SQLiteUserStore) Categories(ctx context.Context) ([]Category, error)

func (SQLiteUserStore) ChatRoomByCookie

func (f SQLiteUserStore) ChatRoomByCookie(ctx context.Context, chatCookie string) (ChatRoom, error)

func (SQLiteUserStore) ChatRoomByName

func (f SQLiteUserStore) ChatRoomByName(ctx context.Context, exchange uint16, name string) (ChatRoom, error)

func (SQLiteUserStore) ClearBuddyListRegistry

func (f SQLiteUserStore) ClearBuddyListRegistry(ctx context.Context) error

func (SQLiteUserStore) ConfirmStatus

func (f SQLiteUserStore) ConfirmStatus(ctx context.Context, screenName IdentScreenName) (bool, error)

func (SQLiteUserStore) CreateAPIKey

func (f SQLiteUserStore) CreateAPIKey(ctx context.Context, key WebAPIKey) error

CreateAPIKey inserts a new API key into the database.

func (SQLiteUserStore) CreateCategory

func (f SQLiteUserStore) CreateCategory(ctx context.Context, name string) (Category, error)

func (SQLiteUserStore) CreateChatRoom

func (f SQLiteUserStore) CreateChatRoom(ctx context.Context, chatRoom *ChatRoom) error

func (SQLiteUserStore) CreateKeyword

func (f SQLiteUserStore) CreateKeyword(ctx context.Context, name string, categoryID uint8) (Keyword, error)

func (SQLiteUserStore) DeleteAPIKey

func (f SQLiteUserStore) DeleteAPIKey(ctx context.Context, devID string) error

DeleteAPIKey removes an API key from the database.

func (SQLiteUserStore) DeleteBARTItem

func (f SQLiteUserStore) DeleteBARTItem(ctx context.Context, hash []byte) error

func (SQLiteUserStore) DeleteCategory

func (f SQLiteUserStore) DeleteCategory(ctx context.Context, categoryID uint8) error

func (SQLiteUserStore) DeleteChatRooms

func (f SQLiteUserStore) DeleteChatRooms(ctx context.Context, exchange uint16, names []string) error

func (SQLiteUserStore) DeleteKeyword

func (f SQLiteUserStore) DeleteKeyword(ctx context.Context, id uint8) error

func (SQLiteUserStore) DeleteMessages

func (f SQLiteUserStore) DeleteMessages(ctx context.Context, recip IdentScreenName) error

func (SQLiteUserStore) DeleteUser

func (f SQLiteUserStore) DeleteUser(ctx context.Context, screenName IdentScreenName) error

func (SQLiteUserStore) DenyBuddy

func (SQLiteUserStore) EmailAddress

func (f SQLiteUserStore) EmailAddress(ctx context.Context, screenName IdentScreenName) (*mail.Address, error)

func (SQLiteUserStore) Feedbag

func (f SQLiteUserStore) Feedbag(ctx context.Context, screenName IdentScreenName) ([]wire.FeedbagItem, error)

func (SQLiteUserStore) FeedbagDelete

func (f SQLiteUserStore) FeedbagDelete(ctx context.Context, screenName IdentScreenName, items []wire.FeedbagItem) error

func (SQLiteUserStore) FeedbagLastModified

func (f SQLiteUserStore) FeedbagLastModified(ctx context.Context, screenName IdentScreenName) (time.Time, error)

func (SQLiteUserStore) FeedbagUpsert

func (f SQLiteUserStore) FeedbagUpsert(ctx context.Context, screenName IdentScreenName, items []wire.FeedbagItem) error

func (SQLiteUserStore) FindByAIMEmail

func (f SQLiteUserStore) FindByAIMEmail(ctx context.Context, email string) (User, error)

func (SQLiteUserStore) FindByAIMKeyword

func (f SQLiteUserStore) FindByAIMKeyword(ctx context.Context, keyword string) ([]User, error)

func (SQLiteUserStore) FindByAIMNameAndAddr

func (f SQLiteUserStore) FindByAIMNameAndAddr(ctx context.Context, info AIMNameAndAddr) ([]User, error)

func (SQLiteUserStore) FindByICQEmail

func (f SQLiteUserStore) FindByICQEmail(ctx context.Context, email string) (User, error)

func (SQLiteUserStore) FindByICQInterests

func (f SQLiteUserStore) FindByICQInterests(ctx context.Context, code uint16, keywords []string) ([]User, error)

func (SQLiteUserStore) FindByICQKeyword

func (f SQLiteUserStore) FindByICQKeyword(ctx context.Context, keyword string) ([]User, error)

func (SQLiteUserStore) FindByICQName

func (f SQLiteUserStore) FindByICQName(ctx context.Context, firstName, lastName, nickName string) ([]User, error)

func (SQLiteUserStore) FindByUIN

func (f SQLiteUserStore) FindByUIN(ctx context.Context, UIN uint32) (User, error)

func (*SQLiteUserStore) FindUserByScreenName

func (u *SQLiteUserStore) FindUserByScreenName(ctx context.Context, screenName IdentScreenName) (*User, error)

FindUserByScreenName finds a user by their screen name. This is just an alias for the User method to satisfy the UserManager interface.

func (SQLiteUserStore) GetAPIKeyByDevID

func (f SQLiteUserStore) GetAPIKeyByDevID(ctx context.Context, devID string) (*WebAPIKey, error)

GetAPIKeyByDevID retrieves an API key by its dev_id value.

func (*SQLiteUserStore) GetAPIKeyByDevKey

func (f *SQLiteUserStore) GetAPIKeyByDevKey(ctx context.Context, devKey string) (*WebAPIKey, error)

GetAPIKeyByDevKey retrieves an API key by its dev_key value.

func (SQLiteUserStore) InsertBARTItem

func (f SQLiteUserStore) InsertBARTItem(ctx context.Context, hash []byte, blob []byte, itemType uint16) error

func (SQLiteUserStore) InsertUser

func (f SQLiteUserStore) InsertUser(ctx context.Context, u User) error

func (SQLiteUserStore) InterestList

func (f SQLiteUserStore) InterestList(ctx context.Context) ([]wire.ODirKeywordListItem, error)

InterestList returns a list of keywords grouped by category used to render the AIM directory interests list. The list is made up of 3 types of elements:

Categories

ID: The category ID
Cookie: The category name
Type: [wire.ODirKeywordCategory]

Keywords

ID: The parent category ID
Cookie: The keyword name
Type: [wire.ODirKeyword]

Top-level Keywords

ID: 0 (does not have a parent category)
Cookie: The keyword name
Type: [wire.ODirKeyword]

Keywords are grouped contiguously by category and preceded by the category name. Top-level keywords appear by themselves. Categories and top-level keywords are sorted alphabetically. Keyword groups are sorted alphabetically.

Conceptually, the list looks like this:

> Animals (top-level keyword, id=0)
> Artificial Intelligence (keyword, id=3)
	> Cybersecurity (keyword, id=3)
> Music (category, id=1)
	> Jazz (keyword, id=1)
	> Rock (keyword, id=1)
> Sports (category, id=2)
	> Basketball (keyword, id=2)
	> Soccer (keyword, id=2)
	> Tennis (keyword, id=2)
> Technology (category, id=3)
> Zoology (top-level keyword, id=0)

func (SQLiteUserStore) KeywordsByCategory

func (f SQLiteUserStore) KeywordsByCategory(ctx context.Context, categoryID uint8) ([]Keyword, error)

func (SQLiteUserStore) ListAPIKeys

func (f SQLiteUserStore) ListAPIKeys(ctx context.Context) ([]WebAPIKey, error)

ListAPIKeys retrieves all API keys from the database.

func (SQLiteUserStore) ListBARTItems

func (f SQLiteUserStore) ListBARTItems(ctx context.Context, itemType uint16) ([]BARTItem, error)

func (*SQLiteUserStore) NewOSCARBridgeStore

func (s *SQLiteUserStore) NewOSCARBridgeStore() *OSCARBridgeStore

NewOSCARBridgeStore creates a new OSCAR bridge store instance.

func (*SQLiteUserStore) NewWebAPIChatManager

func (s *SQLiteUserStore) NewWebAPIChatManager(logger *slog.Logger, sessions *WebAPISessionManager) *WebAPIChatManager

NewWebAPIChatManager creates a new WebAPIChatManager

func (*SQLiteUserStore) NewWebAPITokenStore

func (s *SQLiteUserStore) NewWebAPITokenStore() *WebAPITokenStore

NewWebAPITokenStore creates a new token store.

func (*SQLiteUserStore) NewWebPermitDenyManager

func (s *SQLiteUserStore) NewWebPermitDenyManager() *WebPermitDenyManager

NewWebPermitDenyManager creates a new WebPermitDenyManager.

func (*SQLiteUserStore) NewWebPreferenceManager

func (s *SQLiteUserStore) NewWebPreferenceManager() *WebPreferenceManager

NewWebPreferenceManager creates a new WebPreferenceManager.

func (SQLiteUserStore) PermitBuddy

func (f SQLiteUserStore) PermitBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

func (SQLiteUserStore) Profile

func (f SQLiteUserStore) Profile(ctx context.Context, screenName IdentScreenName) (UserProfile, error)

func (SQLiteUserStore) RegStatus

func (f SQLiteUserStore) RegStatus(ctx context.Context, screenName IdentScreenName) (uint16, error)

func (SQLiteUserStore) RegisterBuddyList

func (f SQLiteUserStore) RegisterBuddyList(ctx context.Context, user IdentScreenName) error

func (SQLiteUserStore) Relationship

Relationship retrieves the relationship between the specified user (`me`) and another user (`them`).

This method always returns a usable Relationship value. If the user specified by `them` does not exist, the returned Relationship will have default boolean values.

func (SQLiteUserStore) RemoveBuddy

func (f SQLiteUserStore) RemoveBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

func (SQLiteUserStore) RemoveDenyBuddy

func (f SQLiteUserStore) RemoveDenyBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

func (SQLiteUserStore) RemovePermitBuddy

func (f SQLiteUserStore) RemovePermitBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

func (SQLiteUserStore) RetrieveMessages

func (f SQLiteUserStore) RetrieveMessages(ctx context.Context, recip IdentScreenName) ([]OfflineMessage, error)

func (SQLiteUserStore) SaveMessage

func (f SQLiteUserStore) SaveMessage(ctx context.Context, offlineMessage OfflineMessage) (newCount int, err error)

func (SQLiteUserStore) SetAffiliations

func (f SQLiteUserStore) SetAffiliations(ctx context.Context, name IdentScreenName, data ICQAffiliations) error

func (SQLiteUserStore) SetBasicInfo

func (f SQLiteUserStore) SetBasicInfo(ctx context.Context, name IdentScreenName, data ICQBasicInfo) error

func (SQLiteUserStore) SetBotStatus

func (f SQLiteUserStore) SetBotStatus(ctx context.Context, isBot bool, screenName IdentScreenName) error

func (SQLiteUserStore) SetDirectoryInfo

func (f SQLiteUserStore) SetDirectoryInfo(ctx context.Context, screenName IdentScreenName, info AIMNameAndAddr) error

func (SQLiteUserStore) SetInterests

func (f SQLiteUserStore) SetInterests(ctx context.Context, name IdentScreenName, data ICQInterests) error

func (SQLiteUserStore) SetKeywords

func (f SQLiteUserStore) SetKeywords(ctx context.Context, screenName IdentScreenName, keywords [5]string) error

func (SQLiteUserStore) SetMoreInfo

func (f SQLiteUserStore) SetMoreInfo(ctx context.Context, name IdentScreenName, data ICQMoreInfo) error

func (SQLiteUserStore) SetOfflineMsgCount

func (f SQLiteUserStore) SetOfflineMsgCount(ctx context.Context, screenName IdentScreenName, count int) error

SetOfflineMsgCount updates the offline message count for a user.

func (SQLiteUserStore) SetPDMode

func (f SQLiteUserStore) SetPDMode(ctx context.Context, me IdentScreenName, pdMode wire.FeedbagPDMode) error

func (SQLiteUserStore) SetProfile

func (f SQLiteUserStore) SetProfile(ctx context.Context, screenName IdentScreenName, profile UserProfile) error

func (SQLiteUserStore) SetTOCConfig

func (f SQLiteUserStore) SetTOCConfig(ctx context.Context, user IdentScreenName, config string) error

func (SQLiteUserStore) SetUserNotes

func (f SQLiteUserStore) SetUserNotes(ctx context.Context, name IdentScreenName, data ICQUserNotes) error

func (SQLiteUserStore) SetUserPassword

func (f SQLiteUserStore) SetUserPassword(ctx context.Context, screenName IdentScreenName, newPassword string) error

func (SQLiteUserStore) SetWarnLevel

func (f SQLiteUserStore) SetWarnLevel(ctx context.Context, user IdentScreenName, lastWarnUpdate time.Time, lastWarnLevel uint16) error

SetWarnLevel updates the last warn update time and warning level for a user.

func (SQLiteUserStore) SetWorkInfo

func (f SQLiteUserStore) SetWorkInfo(ctx context.Context, name IdentScreenName, data ICQWorkInfo) error

func (SQLiteUserStore) UnregisterBuddyList

func (f SQLiteUserStore) UnregisterBuddyList(ctx context.Context, user IdentScreenName) error

func (SQLiteUserStore) UpdateAPIKey

func (f SQLiteUserStore) UpdateAPIKey(ctx context.Context, devID string, updates WebAPIKeyUpdate) error

UpdateAPIKey updates an existing API key's fields.

func (SQLiteUserStore) UpdateConfirmStatus

func (f SQLiteUserStore) UpdateConfirmStatus(ctx context.Context, screenName IdentScreenName, confirmStatus bool) error

func (SQLiteUserStore) UpdateDisplayScreenName

func (f SQLiteUserStore) UpdateDisplayScreenName(ctx context.Context, displayScreenName DisplayScreenName) error

func (SQLiteUserStore) UpdateEmailAddress

func (f SQLiteUserStore) UpdateEmailAddress(ctx context.Context, screenName IdentScreenName, emailAddress *mail.Address) error

func (*SQLiteUserStore) UpdateLastUsed

func (f *SQLiteUserStore) UpdateLastUsed(ctx context.Context, devKey string) error

UpdateLastUsed updates the last_used timestamp for an API key.

func (SQLiteUserStore) UpdateRegStatus

func (f SQLiteUserStore) UpdateRegStatus(ctx context.Context, screenName IdentScreenName, regStatus uint16) error

func (SQLiteUserStore) UpdateSuspendedStatus

func (f SQLiteUserStore) UpdateSuspendedStatus(ctx context.Context, suspendedStatus uint16, screenName IdentScreenName) error

func (SQLiteUserStore) UseFeedbag

func (f SQLiteUserStore) UseFeedbag(ctx context.Context, screenName IdentScreenName) error

func (SQLiteUserStore) User

func (f SQLiteUserStore) User(ctx context.Context, screenName IdentScreenName) (*User, error)

type ServerCookie

type ServerCookie struct {
	Service       uint16
	ScreenName    DisplayScreenName `oscar:"len_prefix=uint8"`
	ClientID      string            `oscar:"len_prefix=uint8"`
	ChatCookie    string            `oscar:"len_prefix=uint8"`
	MultiConnFlag uint8
	// KerberosAuth indicates whether the client used Kerberos for authentication.
	KerberosAuth uint8
	SessionNum   uint8
}

ServerCookie represents a token containing client metadata passed to the BOS service upon connection.

type SessSendStatus

type SessSendStatus int

SessSendStatus is the result of sending a message to a user.

const (
	// SessSendOK indicates message was sent to recipient
	SessSendOK SessSendStatus = iota
	// SessSendClosed indicates send did not complete because session is closed
	SessSendClosed
	// SessQueueFull indicates send failed due to full queue -- client is likely
	// dead
	SessQueueFull
)

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session represents shared user-level state that persists across all concurrent connections for a single user account.

Session maintains client identity information, preferences, rate limiting state, and other shared data that should be consistent across all of a user's active connections. Individual connection-specific state (like remote address, sign-on status, or per-connection capabilities) is stored in SessionInstance instead.

All methods on Session are safe for concurrent use.

func NewSession

func NewSession() *Session

NewSession creates a new Session for a user.

func (*Session) AddInstance

func (s *Session) AddInstance() *SessionInstance

AddInstance creates and adds a new connection instance to the session. Returns the newly created SessionInstance with a unique instance number.

func (*Session) AllUserInfoBitmask

func (s *Session) AllUserInfoBitmask(flag uint16) bool

AllUserInfoBitmask returns whether all instances have user info flag set.

func (*Session) AllUserStatusBitmask

func (s *Session) AllUserStatusBitmask(flag uint32) bool

AllUserStatusBitmask returns whether all instances have user status flag set.

func (*Session) Away

func (s *Session) Away() bool

Away returns true if all instances are away.

func (*Session) AwayMessage

func (s *Session) AwayMessage() string

AwayMessage returns the away message from the last instance to set an away message.

func (*Session) BuddyIcon

func (s *Session) BuddyIcon() (wire.BARTID, bool)

BuddyIcon returns the session's buddy icon metadata and reports whether it has been set.

func (*Session) Caps

func (s *Session) Caps() [][16]byte

Caps returns the union of all capability UUIDs from all instances in the session.

func (*Session) ChatRoomCookie

func (s *Session) ChatRoomCookie() string

ChatRoomCookie returns the chat room cookie.

func (*Session) CloseSession

func (s *Session) CloseSession()

CloseSession closes all instances in the session.

func (*Session) DisplayScreenName

func (s *Session) DisplayScreenName() DisplayScreenName

DisplayScreenName returns the user's display screen name.

func (*Session) EvaluateRateLimit

func (s *Session) EvaluateRateLimit(now time.Time, rateClassID wire.RateLimitClassID) wire.RateLimitStatus

EvaluateRateLimit checks and updates the rate limit state.

func (*Session) HasLiveInstances

func (s *Session) HasLiveInstances() bool

HasLiveInstances returns true if the session has at least one live instance. A live instance is one that is not closed and has completed the sign-on sequence.

func (*Session) IdentScreenName

func (s *Session) IdentScreenName() IdentScreenName

IdentScreenName returns the user's identity screen name.

func (*Session) Idle

func (s *Session) Idle() bool

Idle returns true if all instances are idle.

func (*Session) IdleTime

func (s *Session) IdleTime() time.Time

IdleTime returns the latest idle time if all instances are idle. If not all instances are idle, it returns a zero time.

func (*Session) Inactive

func (s *Session) Inactive() bool

Inactive returns true if all instances are not active.

func (*Session) Instance

func (s *Session) Instance(num uint8) *SessionInstance

Instance returns the SessionInstance with the given instance number, or nil if not found.

func (*Session) InstanceCount

func (s *Session) InstanceCount() int

InstanceCount returns the number of total instances in the session group.

func (*Session) Instances

func (s *Session) Instances() []*SessionInstance

Instances returns all instances in the order they were added.

func (*Session) Invisible

func (s *Session) Invisible() bool

Invisible returns true if all instances are invisible.

func (*Session) MemberSince

func (s *Session) MemberSince() time.Time

MemberSince reports when the user became a member.

func (*Session) ObserveRateChanges

func (s *Session) ObserveRateChanges(now time.Time) (classDelta []RateClassState, stateDelta []RateClassState)

ObserveRateChanges updates rate limit states and returns changes.

func (*Session) OfflineMsgCount

func (s *Session) OfflineMsgCount() int

OfflineMsgCount returns the offline message count.

func (*Session) OnSessionClose

func (s *Session) OnSessionClose(fn func())

OnSessionClose registers a function to be called once all instances have closed.

func (*Session) Profile

func (s *Session) Profile() UserProfile

Profile returns the most recently updated non-empty profile from all instances.

func (*Session) RateLimitStates

func (s *Session) RateLimitStates() [5]RateClassState

RateLimitStates returns the current rate limit states (shared across all sessions).

func (*Session) RemoveInstance

func (s *Session) RemoveInstance(instance *SessionInstance)

RemoveInstance removes an instance from the session group.

func (*Session) RunOnce

func (s *Session) RunOnce(fn func() error) error

RunOnce executes the given function once across all invocations. Used to run arbitrary code that must only run once when the first session instance connects. The function must not block.

func (*Session) ScaleWarningAndRateLimit

func (s *Session) ScaleWarningAndRateLimit(incr int16, classID wire.RateLimitClassID) (bool, uint16)

ScaleWarningAndRateLimit increments the user's warning level and scales rate limits.

func (*Session) SetBuddyIcon

func (s *Session) SetBuddyIcon(icon wire.BARTID)

SetBuddyIcon stores the session's buddy icon metadata.

func (*Session) SetChatRoomCookie

func (s *Session) SetChatRoomCookie(cookie string)

SetChatRoomCookie sets the chat room cookie.

func (*Session) SetDisplayScreenName

func (s *Session) SetDisplayScreenName(displayScreenName DisplayScreenName)

SetDisplayScreenName sets the user's display screen name (shared across all sessions).

func (*Session) SetIdentScreenName

func (s *Session) SetIdentScreenName(screenName IdentScreenName)

SetIdentScreenName sets the user's identity screen name (shared across all sessions).

func (*Session) SetMemberSince

func (s *Session) SetMemberSince(t time.Time)

SetMemberSince sets the member since timestamp.

func (*Session) SetNowFn

func (s *Session) SetNowFn(fn func() time.Time)

SetNowFn sets the function used to get the current time. This is useful for testing.

func (*Session) SetOfflineMsgCount

func (s *Session) SetOfflineMsgCount(count int)

SetOfflineMsgCount sets the offline message count.

func (*Session) SetRateClasses

func (s *Session) SetRateClasses(now time.Time, classes wire.RateLimitClasses)

SetRateClasses sets the rate limit classes (shared across all sessions).

func (*Session) SetSignonTime

func (s *Session) SetSignonTime(t time.Time)

SetSignonTime sets the session's sign-on time.

func (*Session) SetTypingEventsEnabled

func (s *Session) SetTypingEventsEnabled(enabled bool)

SetTypingEventsEnabled sets whether the session wants to send and receive typing events.

func (*Session) SetUIN

func (s *Session) SetUIN(uin uint32)

SetUIN sets the user's ICQ number (shared across all sessions).

func (*Session) SetWarning

func (s *Session) SetWarning(warning uint16)

SetWarning sets the user's warning level (shared across all sessions).

func (*Session) SignonTime

func (s *Session) SignonTime() time.Time

SignonTime returns the session's sign-on time.

func (*Session) SubscribeRateLimits

func (s *Session) SubscribeRateLimits(classes []wire.RateLimitClassID)

SubscribeRateLimits subscribes to rate limit updates.

func (*Session) TLVUserInfo

func (s *Session) TLVUserInfo() wire.TLVUserInfo

TLVUserInfo returns a TLV list containing session information aggregated from all instances.

func (*Session) TypingEventsEnabled

func (s *Session) TypingEventsEnabled() bool

TypingEventsEnabled indicates whether the session wants to send and receive typing events.

func (*Session) UIN

func (s *Session) UIN() uint32

UIN returns the user's ICQ number.

func (*Session) Warning

func (s *Session) Warning() uint16

Warning returns the user's current warning level.

func (*Session) WarningCh

func (s *Session) WarningCh() chan uint16

WarningCh returns the warning notification channel.

type SessionInstance

type SessionInstance struct {
	// contains filtered or unexported fields
}

SessionInstance represents a single client connection instance within a user's session. Multiple SessionInstance objects can belong to the same Session, allowing a user to maintain concurrent connections from different clients or devices.

SessionInstance stores connection-specific state such as the remote address, sign-on completion status, client capabilities, idle state, and per-connection profile data. It holds a reference to its parent Session to access shared user-level data like identity, warning levels, and rate limiting state.

All methods on SessionInstance are safe for concurrent use.

func (*SessionInstance) Away

func (s *SessionInstance) Away() bool

Away returns true if the instance is away.

func (*SessionInstance) AwayMessage

func (s *SessionInstance) AwayMessage() (string, time.Time)

AwayMessage returns the instance's away message and the time it was set.

func (*SessionInstance) ChatRoomCookie

func (s *SessionInstance) ChatRoomCookie() string

ChatRoomCookie returns the chat room cookie from the parent session.

func (*SessionInstance) ClearUserInfoFlag

func (s *SessionInstance) ClearUserInfoFlag(flag uint16) (flags uint16)

ClearUserInfoFlag clears a flag from the user info bitmask.

func (*SessionInstance) ClientID

func (s *SessionInstance) ClientID() string

ClientID retrieves the instance's client ID.

func (*SessionInstance) CloseInstance

func (s *SessionInstance) CloseInstance()

CloseInstance shuts down the instance's ability to relay messages and removes it from the session.

func (*SessionInstance) Closed

func (s *SessionInstance) Closed() <-chan struct{}

Closed blocks until the instance is closed.

func (*SessionInstance) DisplayScreenName

func (s *SessionInstance) DisplayScreenName() DisplayScreenName

DisplayScreenName returns the user's display screen name.

func (*SessionInstance) FoodGroupVersions

func (s *SessionInstance) FoodGroupVersions() [wire.MDir + 1]uint16

FoodGroupVersions retrieves the instance's supported food group versions.

func (*SessionInstance) IdentScreenName

func (s *SessionInstance) IdentScreenName() IdentScreenName

IdentScreenName returns the user's identity screen name.

func (*SessionInstance) Idle

func (s *SessionInstance) Idle() bool

Idle reports the instance's idle state.

func (*SessionInstance) IdleTime

func (s *SessionInstance) IdleTime() time.Time

IdleTime reports when the instance went idle.

func (*SessionInstance) Invisible

func (s *SessionInstance) Invisible() bool

Invisible returns true if the user is invisible.

func (*SessionInstance) KerberosAuth

func (s *SessionInstance) KerberosAuth() bool

KerberosAuth indicates whether Kerberos authentication was used for this instance.

func (*SessionInstance) MultiConnFlag

func (s *SessionInstance) MultiConnFlag() wire.MultiConnFlag

MultiConnFlag retrieves the multi-connection flag for this instance.

func (*SessionInstance) Num

func (s *SessionInstance) Num() uint8

Num returns the unique instance identifier.

func (*SessionInstance) OfflineMsgCount

func (s *SessionInstance) OfflineMsgCount() int

OfflineMsgCount returns the offline message count.

func (*SessionInstance) OnClose

func (s *SessionInstance) OnClose(fn func())

OnClose registers a function to be called when the instance closes, but only if other instances remain in the session. If this is the last instance to close, OnSessionClose will be called instead.

func (*SessionInstance) Profile

func (s *SessionInstance) Profile() UserProfile

Profile returns the user's profile information.

func (*SessionInstance) RateLimitStates

func (s *SessionInstance) RateLimitStates() [5]RateClassState

RateLimitStates returns the current rate limit states.

func (*SessionInstance) ReceiveMessage

func (s *SessionInstance) ReceiveMessage() chan wire.SNACMessage

ReceiveMessage returns a channel of messages relayed via this instance.

func (*SessionInstance) RelayMessageToInstance

func (s *SessionInstance) RelayMessageToInstance(msg wire.SNACMessage) SessSendStatus

RelayMessageToInstance receives a SNAC message and passes it to the instance's message channel.

func (*SessionInstance) RemoteAddr

func (s *SessionInstance) RemoteAddr() (remoteAddr *netip.AddrPort)

RemoteAddr returns the instance's remote IP address.

func (*SessionInstance) Session

func (s *SessionInstance) Session() *Session

Session returns the parent Session for this instance.

func (*SessionInstance) SetAwayMessage

func (s *SessionInstance) SetAwayMessage(awayMessage string)

SetAwayMessage sets the instance's away message.

func (*SessionInstance) SetCaps

func (s *SessionInstance) SetCaps(caps [][16]byte)

SetCaps sets capability UUIDs for the instance.

func (*SessionInstance) SetClientID

func (s *SessionInstance) SetClientID(clientID string)

SetClientID sets the instance's client ID.

func (*SessionInstance) SetFoodGroupVersions

func (s *SessionInstance) SetFoodGroupVersions(versions [wire.MDir + 1]uint16)

SetFoodGroupVersions sets the instance's supported food group versions.

func (*SessionInstance) SetIdle

func (s *SessionInstance) SetIdle(dur time.Duration)

SetIdle sets the instance's idle state.

func (*SessionInstance) SetKerberosAuth

func (s *SessionInstance) SetKerberosAuth(enabled bool)

SetKerberosAuth sets whether Kerberos authentication was used for this instance.

func (*SessionInstance) SetMultiConnFlag

func (s *SessionInstance) SetMultiConnFlag(flag wire.MultiConnFlag)

SetMultiConnFlag sets the multi-connection flag for this instance.

func (*SessionInstance) SetProfile

func (s *SessionInstance) SetProfile(profile UserProfile)

SetProfile sets the user's profile information.

func (*SessionInstance) SetRemoteAddr

func (s *SessionInstance) SetRemoteAddr(remoteAddr *netip.AddrPort)

SetRemoteAddr sets the instance's remote IP address.

func (*SessionInstance) SetSignonComplete

func (s *SessionInstance) SetSignonComplete()

SetSignonComplete indicates that the instance has completed the sign-on sequence.

func (*SessionInstance) SetUserInfoFlag

func (s *SessionInstance) SetUserInfoFlag(flag uint16)

SetUserInfoFlag sets a flag on the user info bitmask.

func (*SessionInstance) SetUserStatusBitmask

func (s *SessionInstance) SetUserStatusBitmask(bitmask uint32)

SetUserStatusBitmask sets the user status bitmask.

func (*SessionInstance) SignonComplete

func (s *SessionInstance) SignonComplete() bool

SignonComplete indicates whether the instance has completed the sign-on sequence.

func (*SessionInstance) SignonTime

func (s *SessionInstance) SignonTime() time.Time

SignonTime returns the session's sign-on time.

func (*SessionInstance) TypingEventsEnabled

func (s *SessionInstance) TypingEventsEnabled() bool

TypingEventsEnabled indicates whether the session wants to send and receive typing events.

func (*SessionInstance) UIN

func (s *SessionInstance) UIN() uint32

UIN returns the user's ICQ number.

func (*SessionInstance) UnsetIdle

func (s *SessionInstance) UnsetIdle()

UnsetIdle removes the instance's idle state.

func (*SessionInstance) UserInfoBitmask

func (s *SessionInstance) UserInfoBitmask() uint16

UserInfoBitmask returns the user info bitmask.

func (*SessionInstance) UserStatusBitmask

func (s *SessionInstance) UserStatusBitmask() uint32

UserStatusBitmask returns the user status bitmask.

func (*SessionInstance) Warning

func (s *SessionInstance) Warning() uint16

Warning returns the user's current warning level.

func (*SessionInstance) WarningCh

func (s *SessionInstance) WarningCh() chan uint16

WarningCh returns the warning notification channel.

type User

type User struct {
	// IdentScreenName is the AIM screen name.
	IdentScreenName IdentScreenName
	// DisplayScreenName is the formatted screen name.
	DisplayScreenName DisplayScreenName
	// AuthKey is the salt for the MD5 password hash.
	AuthKey string
	// StrongMD5Pass is the MD5 password hash format used by AIM v4.8-v5.9.
	StrongMD5Pass []byte
	// WeakMD5Pass is the MD5 password hash format used by AIM v3.5-v4.7. This
	// hash is used to authenticate roasted passwords for AIM v1.0-v3.0.
	WeakMD5Pass []byte
	// IsICQ indicates whether the user is an ICQ account (true) or an AIM
	// account (false).
	IsICQ bool
	// ConfirmStatus indicates whether the user has confirmed their AIM account.
	ConfirmStatus bool
	// RegStatus is the AIM registration status.
	//  1: no disclosure
	//  2: limit disclosure
	//  3: full disclosure
	RegStatus int
	// SuspendedStatus is the account suspended status
	SuspendedStatus uint16
	// EmailAddress is the email address set by the AIM client.
	EmailAddress string
	// ICQAffiliations holds information about the user's affiliations,
	// including past and current affiliations.
	ICQAffiliations ICQAffiliations
	// ICQInterests holds information about the user's interests, categorized
	// by code and associated keywords.
	ICQInterests ICQInterests
	// ICQMoreInfo contains additional information about the user.
	ICQMoreInfo ICQMoreInfo
	// ICQPermissions specifies the user's privacy settings.
	ICQPermissions ICQPermissions
	// ICQBasicInfo contains the user's basic profile information, including
	// contact details and personal identifiers.
	ICQBasicInfo ICQBasicInfo
	// ICQNotes allows the user to store personal notes or additional
	// information within their profile.
	ICQNotes ICQUserNotes
	// ICQWorkInfo contains the user's professional information, including
	// their workplace address and job-related details.
	ICQWorkInfo      ICQWorkInfo
	AIMDirectoryInfo AIMNameAndAddr
	// TOCConfig is the user's saved server-side info (buddy list, etc) for
	// on the TOC service.
	TOCConfig string
	// IsBot indicates whether the user is a bot.
	IsBot bool
	// LastWarnUpdate is the timestamp when the user's warning level was last updated.
	LastWarnUpdate time.Time
	// LastWarnLevel is the warning level when the user last signed off.
	LastWarnLevel uint16
	// OfflineMsgCount is the count of offline messages for the user.
	OfflineMsgCount int
}

User represents a user account.

func NewStubUser

func NewStubUser(screenName DisplayScreenName) (User, error)

NewStubUser creates a new user with canned credentials. The default password is "welcome1". This is typically used for development purposes.

func (*User) Age

func (u *User) Age(timeNow func() time.Time) uint16

Age returns the user's age relative to their birthday and timeNow.

func (*User) HashPassword

func (u *User) HashPassword(passwd string) error

HashPassword computes MD5 hashes of the user's password. It computes both weak and strong variants and stores them in the struct.

func (*User) ValidateHash

func (u *User) ValidateHash(md5Hash []byte) bool

ValidateHash validates MD5-hashed passwords for BUCP auth. It handles hashes used in early AIM 4.x versions ("weak" hashes) and later AIM 4.x-5.x versions ("strong" hashes).

func (*User) ValidatePlaintextPass

func (u *User) ValidatePlaintextPass(plaintextPass []byte) bool

ValidatePlaintextPass validates plaintext passwords used in Kerberos auth.

func (*User) ValidateRoastedJavaPass

func (u *User) ValidateRoastedJavaPass(roastedPass []byte) bool

ValidateRoastedJavaPass validates roasted passwords for the Java AIM client FLAP auth.

func (*User) ValidateRoastedKerberosPass

func (u *User) ValidateRoastedKerberosPass(roastedPass []byte) bool

ValidateRoastedKerberosPass validates roasted passwords used in Kerberos auth.

func (*User) ValidateRoastedPass

func (u *User) ValidateRoastedPass(roastedPass []byte) bool

ValidateRoastedPass validates roasted passwords for FLAP auth.

func (*User) ValidateRoastedTOCPass

func (u *User) ValidateRoastedTOCPass(roastedPass []byte) bool

ValidateRoastedTOCPass validates roasted passwords for TOC auth.

type UserProfile

type UserProfile struct {
	// ProfileText is the free-form profile body content.
	ProfileText string
	// MIMEType is the MIME type of the profile content.
	MIMEType string
	// UpdateTime is when the profile was last updated.
	UpdateTime time.Time
}

UserProfile represents a user's profile information.

func (UserProfile) IsEmpty

func (p UserProfile) IsEmpty() bool

IsEmpty returns true of the profile is empty (including not set).

func (UserProfile) IsZero

func (p UserProfile) IsZero() bool

IsZero returns true if the profile has not been set.

type VanityInfo

type VanityInfo struct {
	ScreenName  string                 `json:"screenName"`
	VanityURL   string                 `json:"vanityUrl"`
	DisplayName string                 `json:"displayName,omitempty"`
	Bio         string                 `json:"bio,omitempty"`
	Location    string                 `json:"location,omitempty"`
	Website     string                 `json:"website,omitempty"`
	ProfileURL  string                 `json:"profileUrl"`
	IsActive    bool                   `json:"isActive"`
	Extra       map[string]interface{} `json:"extra,omitempty"`
}

VanityInfo represents the response for vanity URL lookups.

type VanityURL

type VanityURL struct {
	ScreenName   string     `json:"screenName"`
	VanityURL    string     `json:"vanityUrl"`
	DisplayName  string     `json:"displayName,omitempty"`
	Bio          string     `json:"bio,omitempty"`
	Location     string     `json:"location,omitempty"`
	Website      string     `json:"website,omitempty"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
	IsActive     bool       `json:"isActive"`
	ClickCount   int        `json:"clickCount"`
	LastAccessed *time.Time `json:"lastAccessed,omitempty"`
}

VanityURL represents a user's vanity URL configuration.

type VanityURLManager

type VanityURLManager struct {
	// contains filtered or unexported fields
}

VanityURLManager manages vanity URL operations.

func NewVanityURLManager

func NewVanityURLManager(db *sql.DB, logger *slog.Logger, baseURL string) *VanityURLManager

NewVanityURLManager creates a new vanity URL manager.

func (*VanityURLManager) CheckAvailability

func (m *VanityURLManager) CheckAvailability(ctx context.Context, vanityURL string) (bool, error)

CheckAvailability checks if a vanity URL is available.

func (*VanityURLManager) CreateOrUpdateVanityURL

func (m *VanityURLManager) CreateOrUpdateVanityURL(ctx context.Context, screenName string, vanityURL string, info map[string]interface{}) error

CreateOrUpdateVanityURL creates or updates a vanity URL for a user.

func (*VanityURLManager) DeleteVanityURL

func (m *VanityURLManager) DeleteVanityURL(ctx context.Context, screenName string) error

DeleteVanityURL removes a user's vanity URL.

func (*VanityURLManager) GetPopularVanityURLs

func (m *VanityURLManager) GetPopularVanityURLs(ctx context.Context, limit int) ([]VanityInfo, error)

GetPopularVanityURLs retrieves the most accessed vanity URLs.

func (*VanityURLManager) GetVanityInfo

func (m *VanityURLManager) GetVanityInfo(ctx context.Context, vanityURL string) (*VanityInfo, error)

GetVanityInfo retrieves vanity URL information.

func (*VanityURLManager) GetVanityInfoByScreenName

func (m *VanityURLManager) GetVanityInfoByScreenName(ctx context.Context, screenName string) (*VanityInfo, error)

GetVanityInfoByScreenName retrieves vanity URL info by screen name.

func (*VanityURLManager) LogRedirect

func (m *VanityURLManager) LogRedirect(ctx context.Context, redirect VanityURLRedirect) error

LogRedirect logs a vanity URL redirect for analytics.

type VanityURLRedirect

type VanityURLRedirect struct {
	ID         int64     `json:"id"`
	VanityURL  string    `json:"vanityUrl"`
	AccessedAt time.Time `json:"accessedAt"`
	IPAddress  string    `json:"ipAddress,omitempty"`
	UserAgent  string    `json:"userAgent,omitempty"`
	Referer    string    `json:"referer,omitempty"`
}

VanityURLRedirect represents a vanity URL access record.

type WebAPIChatManager

type WebAPIChatManager struct {
	// contains filtered or unexported fields
}

WebAPIChatManager manages Web API chat rooms

func (*WebAPIChatManager) CleanupInactiveSessions

func (m *WebAPIChatManager) CleanupInactiveSessions(ctx context.Context)

CleanupInactiveSessions removes sessions that have been inactive for too long

func (*WebAPIChatManager) CreateAndJoinChat

func (m *WebAPIChatManager) CreateAndJoinChat(ctx context.Context, aimsid, roomID, roomName, screenName string) (*ChatSession, *WebAPIChatRoom, error)

CreateAndJoinChat creates a new chat room or joins an existing one

func (*WebAPIChatManager) GetRecentMessages

func (m *WebAPIChatManager) GetRecentMessages(ctx context.Context, roomID string, limit int) ([]*ChatMessage, error)

GetRecentMessages returns recent messages from a chat room (for history)

func (*WebAPIChatManager) LeaveChat

func (m *WebAPIChatManager) LeaveChat(ctx context.Context, chatsid string) error

LeaveChat removes a user from a chat room

func (*WebAPIChatManager) SendMessage

func (m *WebAPIChatManager) SendMessage(ctx context.Context, chatsid, message, whisperTarget string) error

SendMessage sends a message to a chat room

func (*WebAPIChatManager) SetTyping

func (m *WebAPIChatManager) SetTyping(ctx context.Context, chatsid, typingStatus string) error

SetTyping sets the typing status for a user in a chat room

type WebAPIChatRoom

type WebAPIChatRoom struct {
	RoomID            string       `json:"roomId"`
	RoomName          string       `json:"roomName"`
	Description       string       `json:"description,omitempty"`
	RoomType          ChatRoomType `json:"roomType"`
	CategoryID        string       `json:"categoryId,omitempty"`
	CreatorScreenName string       `json:"-"` // Internal only
	CreatedAt         int64        `json:"-"`
	ClosedAt          *int64       `json:"-"`
	MaxParticipants   int          `json:"-"`
	InstanceID        int          `json:"instanceId"`
}

WebAPIChatRoom represents a chat room for Web API

type WebAPIKey

type WebAPIKey struct {
	DevID          string     `json:"dev_id"`
	DevKey         string     `json:"dev_key"`
	AppName        string     `json:"app_name"`
	CreatedAt      time.Time  `json:"created_at"`
	LastUsed       *time.Time `json:"last_used,omitempty"`
	IsActive       bool       `json:"is_active"`
	RateLimit      int        `json:"rate_limit"`
	AllowedOrigins []string   `json:"allowed_origins"`
	Capabilities   []string   `json:"capabilities"`
}

WebAPIKey represents a Web API authentication key.

type WebAPIKeyUpdate

type WebAPIKeyUpdate struct {
	AppName        *string   `json:"app_name,omitempty"`
	IsActive       *bool     `json:"is_active,omitempty"`
	RateLimit      *int      `json:"rate_limit,omitempty"`
	AllowedOrigins *[]string `json:"allowed_origins,omitempty"`
	Capabilities   *[]string `json:"capabilities,omitempty"`
}

WebAPIKeyUpdate represents fields that can be updated for an API key.

type WebAPISession

type WebAPISession struct {
	AimSID          string            // Unique session ID for web client
	ScreenName      DisplayScreenName // User identity
	OSCARSession    *SessionInstance  // Bridge to existing OSCAR session
	Events          []string          // Subscribed event types
	EventQueue      *types.EventQueue // Per-session event queue
	DevID           string            // Developer ID that created this session
	ClientName      string            // Client application name
	ClientVersion   string            // Client application version
	CreatedAt       time.Time         // SessionInstance creation time
	LastAccessed    time.Time         // Last activity time
	ExpiresAt       time.Time         // SessionInstance expiration time
	FetchTimeout    int               // Long-polling timeout in milliseconds
	TimeToNextFetch int               // Suggested delay before next fetch
	RemoteAddr      string            // Client IP address
	TempBuddies     map[string]bool   // Temporary buddies for this session only
	// contains filtered or unexported fields
}

WebAPISession represents an active Web AIM API session.

func (*WebAPISession) IsExpired

func (s *WebAPISession) IsExpired() bool

IsExpired checks if the session has expired.

func (*WebAPISession) IsSubscribedTo

func (s *WebAPISession) IsSubscribedTo(eventType string) bool

IsSubscribedTo checks if the session is subscribed to a specific event type.

func (*WebAPISession) StartListeningToOSCARSession

func (s *WebAPISession) StartListeningToOSCARSession()

StartListeningToOSCARSession starts a goroutine that listens to the OSCAR session's message channel and converts SNAC messages into WebAPI events.

func (*WebAPISession) Touch

func (s *WebAPISession) Touch()

Touch updates the last accessed time and extends expiration if needed.

type WebAPISessionManager

type WebAPISessionManager struct {
	// contains filtered or unexported fields
}

WebAPISessionManager manages Web API sessions with thread-safe operations.

func NewWebAPISessionManager

func NewWebAPISessionManager() *WebAPISessionManager

NewWebAPISessionManager creates a new WebAPI session manager.

func (*WebAPISessionManager) CreateSession

func (m *WebAPISessionManager) CreateSession(ctx context.Context, screenName DisplayScreenName, devID string, events []string, oscarSession *SessionInstance, logger *slog.Logger) (*WebAPISession, error)

CreateSession creates a new WebAPI session.

func (*WebAPISessionManager) GetAllSessions

func (m *WebAPISessionManager) GetAllSessions(ctx context.Context) []*WebAPISession

GetAllSessions returns all active sessions (for monitoring/admin).

func (*WebAPISessionManager) GetSession

func (m *WebAPISessionManager) GetSession(ctx context.Context, aimsid string) (*WebAPISession, error)

GetSession retrieves a session by aimsid.

func (*WebAPISessionManager) GetSessionByUser

func (m *WebAPISessionManager) GetSessionByUser(ctx context.Context, screenName IdentScreenName) (*WebAPISession, error)

GetSessionByUser retrieves a session by screen name.

func (*WebAPISessionManager) GetSessionsByScreenName

func (m *WebAPISessionManager) GetSessionsByScreenName(ctx context.Context, screenName DisplayScreenName) []*WebAPISession

GetSessionsByScreenName returns all sessions for a given screen name.

func (*WebAPISessionManager) RemoveSession

func (m *WebAPISessionManager) RemoveSession(ctx context.Context, aimsid string) error

RemoveSession removes a session by aimsid.

func (*WebAPISessionManager) Shutdown

func (m *WebAPISessionManager) Shutdown(ctx context.Context)

Shutdown stops the session manager and cleans up resources.

func (*WebAPISessionManager) TouchSession

func (m *WebAPISessionManager) TouchSession(ctx context.Context, aimsid string) error

TouchSession updates the last accessed time for a session.

type WebAPITokenStore

type WebAPITokenStore struct {
	// contains filtered or unexported fields
}

WebAPITokenStore manages authentication tokens for Web API sessions.

func (*WebAPITokenStore) CleanupExpiredTokens

func (s *WebAPITokenStore) CleanupExpiredTokens(ctx context.Context) error

CleanupExpiredTokens removes all expired tokens from the database.

func (*WebAPITokenStore) DeleteToken

func (s *WebAPITokenStore) DeleteToken(ctx context.Context, token string) error

DeleteToken removes a token.

func (*WebAPITokenStore) StoreToken

func (s *WebAPITokenStore) StoreToken(ctx context.Context, token string, screenName IdentScreenName, expiresAt time.Time) error

StoreToken saves an authentication token for a user.

func (*WebAPITokenStore) ValidateToken

func (s *WebAPITokenStore) ValidateToken(ctx context.Context, token string) (IdentScreenName, error)

ValidateToken checks if a token is valid and returns the associated screen name.

type WebPermitDenyManager

type WebPermitDenyManager struct {
	// contains filtered or unexported fields
}

WebPermitDenyManager handles Web API permit/deny list management.

func (*WebPermitDenyManager) AddDenyBuddy

AddDenyBuddy adds a user to the deny list.

func (*WebPermitDenyManager) AddPermitBuddy

func (m *WebPermitDenyManager) AddPermitBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

AddPermitBuddy adds a user to the permit list.

func (*WebPermitDenyManager) GetDenyList

func (m *WebPermitDenyManager) GetDenyList(ctx context.Context, screenName IdentScreenName) ([]IdentScreenName, error)

GetDenyList retrieves the deny list for a user.

func (*WebPermitDenyManager) GetPDMode

func (m *WebPermitDenyManager) GetPDMode(ctx context.Context, screenName IdentScreenName) (wire.FeedbagPDMode, error)

GetPDMode retrieves the permit/deny mode for a user.

func (*WebPermitDenyManager) GetPermitList

func (m *WebPermitDenyManager) GetPermitList(ctx context.Context, screenName IdentScreenName) ([]IdentScreenName, error)

GetPermitList retrieves the permit list for a user.

func (*WebPermitDenyManager) RemoveDenyBuddy

func (m *WebPermitDenyManager) RemoveDenyBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

RemoveDenyBuddy removes a user from the deny list.

func (*WebPermitDenyManager) RemovePermitBuddy

func (m *WebPermitDenyManager) RemovePermitBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

RemovePermitBuddy removes a user from the permit list.

func (*WebPermitDenyManager) SetPDMode

func (m *WebPermitDenyManager) SetPDMode(ctx context.Context, screenName IdentScreenName, mode wire.FeedbagPDMode) error

SetPDMode sets the permit/deny mode for a user.

type WebPreferenceManager

type WebPreferenceManager struct {
	// contains filtered or unexported fields
}

WebPreferenceManager handles Web API user preferences.

func (*WebPreferenceManager) GetPreferences

func (m *WebPreferenceManager) GetPreferences(ctx context.Context, screenName IdentScreenName) (map[string]interface{}, error)

GetPreferences retrieves user preferences from the database.

func (*WebPreferenceManager) SetPreferences

func (m *WebPreferenceManager) SetPreferences(ctx context.Context, screenName IdentScreenName, prefs map[string]interface{}) error

SetPreferences stores user preferences in the database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL