foodgroup

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package foodgroup implements OSCAR food group business logic.

The OSCAR protocol passes messages in SNAC (Simple Network Atomic Communication) format. SNAC messages are grouped by "food groups" (get it? snack, snac, foodgroup...). Each food group is responsible for a discrete piece of functionality, such as buddy list management (Feedbag), instant messaging (ICBM), and chat messaging (Chat).

Each food group operation is represented by a struct type. The methods correspond 1:1 to each food group operation. Each food group operation is typically triggered by a client request. The operation may return a response. As such, methods receive client requests via SNAC frame and body parameters and send responses via returned SNAC objects.

The following is a typical food group method signature. This example illustrates the ICBM ChannelMsgToHost operation.

ChannelMsgToHost(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, inBody wire.SNAC_0x04_0x06_ICBMChannelMsgToHost) (*wire.SNACMessage, error)

Params:

  • ctx context.Context is the client request context.
  • sess *state.Session is the client's session object.
  • inFrame wire.SNACFrame is the request SNAC frame that contains the food group and subgroup parameters.
  • inBody wire.SNAC_0x04_0x06_ICBMChannelMsgToHost contains the body of the SNAC message. In this case, it contains instant message text and metadata.

ChannelMsgToHost optionally sends a client response by returning *wire.SNACMessage. For operations that always send client responses, the methods return wire.SNACMessage value types (not pointer types). Methods for operations that never send client responses do not return wire.SNACMessage values.

The foodgroup package delegates responsibility for message transport, user retrieval, and session management to callers via several interface types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountManager added in v0.9.0

type AccountManager interface {
	UpdateDisplayScreenName(displayScreenName state.DisplayScreenName) error
	UpdateEmailAddress(emailAddress *mail.Address, screenName state.IdentScreenName) error
	EmailAddressByName(screenName state.IdentScreenName) (*mail.Address, error)
	UpdateRegStatus(regStatus uint16, screenName state.IdentScreenName) error
	RegStatusByName(screenName state.IdentScreenName) (uint16, error)
	UpdateConfirmStatus(confirmStatus bool, screenName state.IdentScreenName) error
	ConfirmStatusByName(screnName state.IdentScreenName) (bool, error)
}

type AdminService added in v0.9.0

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

AdminService provides functionality for the Admin food group. The Admin food group is used for client control of passwords, screen name formatting, email address, and account confirmation.

func NewAdminService added in v0.9.0

func NewAdminService(
	accountManager AccountManager,
	buddyListRetriever BuddyListRetriever,
	messageRelayer MessageRelayer,
	sessionRetriever SessionRetriever,
) *AdminService

NewAdminService creates an instance of AdminService.

func (AdminService) ConfirmRequest added in v0.9.0

func (s AdminService) ConfirmRequest(ctx context.Context, sess *state.Session, frame wire.SNACFrame) (wire.SNACMessage, error)

ConfirmRequest will mark the user account as confirmed if the user has an email address set

func (AdminService) InfoChangeRequest added in v0.9.0

InfoChangeRequest handles the user changing account information

func (AdminService) InfoQuery added in v0.9.0

InfoQuery returns the requested information about the account

type AuthService

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

AuthService provides client login and session management services. It supports both FLAP (AIM v1.0-v3.0) and BUCP (AIM v3.5-v5.9) authentication modes.

func NewAuthService

func NewAuthService(
	cfg config.Config,
	sessionManager SessionRegistry,
	chatSessionRegistry ChatSessionRegistry,
	userManager UserManager,
	cookieBaker CookieBaker,
	messageRelayer MessageRelayer,
	chatMessageRelayer ChatMessageRelayer,
	accountManager AccountManager,
	buddyListRetriever BuddyListRetriever,
	adminServerSessionRetriever SessionRetriever,
) *AuthService

NewAuthService creates a new instance of AuthService.

func (AuthService) BUCPChallenge added in v0.4.0

func (s AuthService) BUCPChallenge(
	bodyIn wire.SNAC_0x17_0x06_BUCPChallengeRequest,
	newUUIDFn func() uuid.UUID,
) (wire.SNACMessage, error)

BUCPChallenge processes a BUCP authentication challenge request. It retrieves the user's auth key based on the screen name provided in the request. The client uses the auth key to salt the MD5 password hash provided in the subsequent login request. If the account is valid, return SNAC(0x17,0x07), otherwise return SNAC(0x17,0x03).

func (AuthService) BUCPLogin added in v0.4.0

func (s AuthService) BUCPLogin(
	bodyIn wire.SNAC_0x17_0x02_BUCPLoginRequest,
	newUserFn func(screenName state.DisplayScreenName) (state.User, error),
) (wire.SNACMessage, error)

BUCPLogin processes a BUCP authentication request for AIM v3.5-v5.9. Upon successful login, a session is created. If login credentials are invalid and app config DisableAuth is true, a stub user is created and login continues as normal. DisableAuth allows you to skip the account creation procedure, which simplifies the login flow during development. If login is successful, the SNAC TLV list contains the BOS server address (wire.LoginTLVTagsReconnectHere) and an authorization cookie (wire.LoginTLVTagsAuthorizationCookie). Else, an error code is set (wire.LoginTLVTagsErrorSubcode).

func (AuthService) FLAPLogin added in v0.4.0

func (s AuthService) FLAPLogin(
	frame wire.FLAPSignonFrame,
	newUserFn func(screenName state.DisplayScreenName) (state.User, error),
) (wire.TLVRestBlock, error)

FLAPLogin processes a FLAP authentication request for AIM v1.0-v3.0. Upon successful login, a session is created. If login credentials are invalid and app config DisableAuth is true, a stub user is created and login continues as normal. DisableAuth allows you to skip the account creation procedure, which simplifies the login flow during development. If login is successful, the SNAC TLV list contains the BOS server address (wire.LoginTLVTagsReconnectHere) and an authorization cookie (wire.LoginTLVTagsAuthorizationCookie). Else, an error code is set (wire.LoginTLVTagsErrorSubcode).

func (AuthService) RegisterBOSSession added in v0.7.0

func (s AuthService) RegisterBOSSession(authCookie []byte) (*state.Session, error)

RegisterBOSSession adds a new session to the session registry.

func (AuthService) RegisterChatSession added in v0.7.0

func (s AuthService) RegisterChatSession(authCookie []byte) (*state.Session, error)

RegisterChatSession adds a user to a chat room. The authCookie param is an opaque token returned by {{OServiceService.ServiceRequest}} that identifies the user and chat room. It returns the session object registered in the ChatSessionRegistry. This method does not verify that the user and chat room exist because it implicitly trusts the contents of the token signed by {{OServiceService.ServiceRequest}}.

func (AuthService) RetrieveBOSSession

func (s AuthService) RetrieveBOSSession(authCookie []byte) (*state.Session, error)

RetrieveBOSSession returns a user's existing session

func (AuthService) Signout

func (s AuthService) Signout(ctx context.Context, sess *state.Session) error

Signout removes this user's session and notifies users who have this user on their buddy list about this user's departure.

func (AuthService) SignoutChat

func (s AuthService) SignoutChat(ctx context.Context, sess *state.Session)

SignoutChat removes user from chat room and notifies remaining participants of their departure.

type BARTManager

type BARTManager interface {
	BARTUpsert(itemHash []byte, payload []byte) error
	BARTRetrieve(itemHash []byte) ([]byte, error)
}

type BARTService

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

func NewBARTService

func NewBARTService(
	logger *slog.Logger,
	bartManager BARTManager,
	messageRelayer MessageRelayer,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) BARTService

func (BARTService) RetrieveItem

RetrieveItem fetches a BART item from the data store. The item is selected based on inBody.Hash. It's unclear what effect inBody.Flags is supposed to have on the request.

func (BARTService) UpsertItem

type BuddyListRetriever added in v0.14.0

type BuddyListRetriever interface {
	AllRelationships(screenName state.IdentScreenName, filter []state.IdentScreenName) ([]state.Relationship, error)
	BuddyIconRefByName(screenName state.IdentScreenName) (*wire.BARTID, error)
	Relationship(me state.IdentScreenName, them state.IdentScreenName) (state.Relationship, error)
}

type BuddyService

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

BuddyService provides functionality for the Buddy food group.

func NewBuddyService

func NewBuddyService(
	messageRelayer MessageRelayer,
	localBuddyListManager LocalBuddyListManager,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) *BuddyService

NewBuddyService creates a new instance of BuddyService.

func (BuddyService) AddBuddies added in v0.3.0

func (s BuddyService) AddBuddies(
	ctx context.Context,
	sess *state.Session,
	inBody wire.SNAC_0x03_0x04_BuddyAddBuddies,
) error

AddBuddies adds buddies to my client-side buddy list.

func (BuddyService) DelBuddies added in v0.3.0

func (s BuddyService) DelBuddies(
	ctx context.Context,
	sess *state.Session,
	inBody wire.SNAC_0x03_0x05_BuddyDelBuddies,
) error

DelBuddies deletes buddies from my client-side buddy list.

func (BuddyService) RightsQuery

func (s BuddyService) RightsQuery(_ context.Context, frameIn wire.SNACFrame) wire.SNACMessage

RightsQuery returns buddy list service parameters.

type ChatMessageRelayer

type ChatMessageRelayer interface {
	// AllSessions returns all chat room participants. Returns
	// ErrChatRoomNotFound if the room does not exist.
	AllSessions(chatCookie string) []*state.Session

	// 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.
	RelayToAllExcept(ctx context.Context, chatCookie string, except state.IdentScreenName, msg wire.SNACMessage)

	// RelayToScreenName sends a message to a chat room user. Returns
	// ErrChatRoomNotFound if the room does not exist for cookie.
	RelayToScreenName(ctx context.Context, chatCookie string, recipient state.IdentScreenName, msg wire.SNACMessage)
}

ChatMessageRelayer defines the interface for sending messages to chat room participants.

type ChatNavService

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

ChatNavService provides functionality for the ChatNav food group, which handles chat room creation and serving chat room metadata.

func NewChatNavService

func NewChatNavService(logger *slog.Logger, chatRoomManager ChatRoomRegistry) *ChatNavService

NewChatNavService creates a new instance of NewChatNavService.

func (ChatNavService) CreateRoom

CreateRoom creates and returns a chat room or returns an existing chat room. It returns SNAC wire.ChatNavNavInfo, which contains metadata for the chat room.

func (ChatNavService) ExchangeInfo added in v0.6.0

func (ChatNavService) RequestChatRights

func (s ChatNavService) RequestChatRights(_ context.Context, inFrame wire.SNACFrame) wire.SNACMessage

RequestChatRights returns SNAC wire.ChatNavNavInfo, which contains chat navigation service parameters and limits.

func (ChatNavService) RequestRoomInfo

RequestRoomInfo returns wire.ChatNavNavInfo, which contains metadata for the chat room specified in the inFrame.hmacCookie.

type ChatRoomRegistry added in v0.8.0

type ChatRoomRegistry interface {
	// ChatRoomByCookie looks up a chat room by exchange. Returns
	// ErrChatRoomNotFound if the room does not exist for cookie.
	ChatRoomByCookie(chatCookie string) (state.ChatRoom, error)

	// ChatRoomByName looks up a chat room by exchange and name. Returns
	// ErrChatRoomNotFound if the room does not exist for exchange and name.
	ChatRoomByName(exchange uint16, name string) (state.ChatRoom, error)

	// CreateChatRoom creates a new chat room.
	CreateChatRoom(chatRoom *state.ChatRoom) error
}

ChatRoomRegistry defines the interface for storing and retrieving chat rooms in a persistent store. The persistent store has two purposes: - Remember user-created chat rooms (exchange 4) so that clients can reconnect to the rooms following server restarts. - Keep track of public chat room created by the server operator (exchange 5). User's can only join public chat rooms that exist in the room registry.

type ChatService

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

ChatService provides functionality for the Chat food group, which is responsible for sending and receiving chat messages.

func NewChatService

func NewChatService(chatMessageRelayer ChatMessageRelayer) *ChatService

NewChatService creates a new instance of ChatService.

func (ChatService) ChannelMsgToHost

ChannelMsgToHost relays wire.ChatChannelMsgToClient SNAC sent from a user to the other chat room participants. It returns the same wire.ChatChannelMsgToClient message back to the user if the chat reflection TLV flag is set, otherwise return nil.

type ChatSessionRegistry added in v0.8.0

type ChatSessionRegistry interface {
	// AddSession adds a session to the chat session manager. The chatCookie
	// param identifies the chat room to which screenName is added. It returns
	// the newly created session instance registered in the chat session
	// manager.
	AddSession(chatCookie string, screenName state.DisplayScreenName) *state.Session

	// RemoveSession removes a session from the chat session manager.
	RemoveSession(sess *state.Session)
}

ChatSessionRegistry defines the interface for adding and removing chat sessions.

type CookieBaker added in v0.7.0

type CookieBaker interface {
	Crack(data []byte) ([]byte, error)
	Issue(data []byte) ([]byte, error)
}

type FeedbagManager

type FeedbagManager interface {
	Feedbag(screenName state.IdentScreenName) ([]wire.FeedbagItem, error)
	FeedbagDelete(screenName state.IdentScreenName, items []wire.FeedbagItem) error
	FeedbagLastModified(screenName state.IdentScreenName) (time.Time, error)
	FeedbagUpsert(screenName state.IdentScreenName, items []wire.FeedbagItem) error
	UseFeedbag(user state.IdentScreenName) error
}

type FeedbagService

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

FeedbagService provides functionality for the Feedbag food group, which handles buddy list management.

func NewFeedbagService

func NewFeedbagService(
	logger *slog.Logger,
	messageRelayer MessageRelayer,
	feedbagManager FeedbagManager,
	bartManager BARTManager,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) FeedbagService

NewFeedbagService creates a new instance of FeedbagService.

func (FeedbagService) DeleteItem

DeleteItem removes items from feedbag (aka buddy list). Sends user buddy arrival notifications for each online & visible buddy added to the feedbag. Sends buddy arrival notifications to each unblocked buddy if current user is visible. It returns wire.FeedbagStatus, which contains update confirmation.

func (FeedbagService) Query

Query fetches the user's feedbag (aka buddy list). It returns wire.FeedbagReply, which contains feedbag entries.

func (FeedbagService) QueryIfModified

QueryIfModified fetches the user's feedbag (aka buddy list). It returns wire.FeedbagReplyNotModified if the feedbag was last modified before inBody.LastUpdate, else return wire.FeedbagReply, which contains feedbag entries.

func (FeedbagService) RespondAuthorizeToHost added in v0.11.0

func (s FeedbagService) RespondAuthorizeToHost(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, inBody wire.SNAC_0x13_0x1A_FeedbagRespondAuthorizeToHost) error

RespondAuthorizeToHost forwards an authorization response from the user whose authorization was requested to the user who made the authorization request. Right now we send an ICBM request so that responses can work for both ICQ 2000b and ICQ 2001a. This function should eventually only send an ICBM message to non-feedbag clients and SNAC(0x0013,0x001B) to feedbag clients.

func (FeedbagService) RightsQuery

func (s FeedbagService) RightsQuery(_ context.Context, inFrame wire.SNACFrame) wire.SNACMessage

RightsQuery returns SNAC wire.FeedbagRightsReply, which contains Feedbag food group settings for the current user. The values within the SNAC are not well understood but seem to make the AIM client happy.

func (FeedbagService) StartCluster

StartCluster exists to capture the SNAC input in unit tests to verify it's correctly unmarshalled.

func (FeedbagService) UpsertItem

func (s FeedbagService) UpsertItem(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, items []wire.FeedbagItem) (wire.SNACMessage, error)

UpsertItem updates items in the user's feedbag (aka buddy list). Sends user buddy arrival notifications for each online & visible buddy added to the feedbag. Sends a buddy departure notification to blocked buddies if current user is visible. It returns wire.FeedbagStatus, which contains insert confirmation. UpdateItem updates items in the user's feedbag (aka buddy list). Sends user buddy arrival notifications for each online & visible buddy added to the feedbag. It returns wire.FeedbagStatus, which contains update confirmation.

func (FeedbagService) Use added in v0.3.0

func (s FeedbagService) Use(ctx context.Context, sess *state.Session) error

Use sends a user the contents of their buddy list. It's invoked at sign-on by AIM clients that use the feedbag food group for buddy list management (as opposed to client-side management).

type ICBMService

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

ICBMService provides functionality for the ICBM food group, which is responsible for sending and receiving instant messages and associated functionality such as warning, typing events, etc.

func NewICBMService

func NewICBMService(
	messageRelayer MessageRelayer,
	offlineMessageSaver OfflineMessageManager,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) *ICBMService

NewICBMService returns a new instance of ICBMService.

func (ICBMService) ChannelMsgToHost

ChannelMsgToHost relays the instant message SNAC wire.ICBMChannelMsgToHost from the sender to the intended recipient. It returns wire.ICBMHostAck if the wire.ICBMChannelMsgToHost message contains a request acknowledgement flag.

func (ICBMService) ClientErr added in v0.11.0

func (s ICBMService) ClientErr(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, inBody wire.SNAC_0x04_0x0B_ICBMClientErr) error

func (ICBMService) ClientEvent

func (s ICBMService) ClientEvent(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, inBody wire.SNAC_0x04_0x14_ICBMClientEvent) error

ClientEvent relays SNAC wire.ICBMClientEvent typing events from the sender to the recipient.

func (ICBMService) EvilRequest

EvilRequest handles user warning (a.k.a evil) notifications. It receives wire.ICBMEvilRequest warning SNAC, increments the warned user's warning level, and sends the warned user a notification informing them that they have been warned. The user may choose to warn anonymously or non-anonymously. It returns SNAC wire.ICBMEvilReply to confirm that the warning was sent. Users may not warn themselves or warn users they have blocked or are blocked by.

func (ICBMService) ParameterQuery

func (s ICBMService) ParameterQuery(_ context.Context, inFrame wire.SNACFrame) wire.SNACMessage

ParameterQuery returns ICBM service parameters.

type ICQService added in v0.10.0

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

ICQService provides functionality for the ICQ food group.

func NewICQService added in v0.10.0

func NewICQService(
	messageRelayer MessageRelayer,
	finder ICQUserFinder,
	userUpdater ICQUserUpdater,
	logger *slog.Logger,
	sessionRetriever SessionRetriever,
	offlineMessageManager OfflineMessageManager,
) ICQService

NewICQService creates an instance of ICQService.

func (ICQService) DeleteMsgReq added in v0.10.0

func (s ICQService) DeleteMsgReq(ctx context.Context, sess *state.Session, seq uint16) error

func (ICQService) FindByEmail3 added in v0.11.0

func (ICQService) FindByICQEmail added in v0.12.0

func (ICQService) FindByICQInterests added in v0.12.0

func (ICQService) FindByICQName added in v0.12.0

func (ICQService) FindByUIN added in v0.10.0

func (ICQService) FindByUIN2 added in v0.11.0

func (ICQService) FindByWhitePages2 added in v0.11.0

func (ICQService) FullUserInfo added in v0.10.0

func (ICQService) OfflineMsgReq added in v0.10.0

func (s ICQService) OfflineMsgReq(ctx context.Context, sess *state.Session, seq uint16) error

func (ICQService) SetAffiliations added in v0.10.0

func (ICQService) SetBasicInfo added in v0.10.0

func (ICQService) SetEmails added in v0.10.0

func (ICQService) SetInterests added in v0.10.0

func (ICQService) SetMoreInfo added in v0.10.0

func (ICQService) SetPermissions added in v0.10.0

func (ICQService) SetUserNotes added in v0.10.0

func (ICQService) SetWorkInfo added in v0.10.0

func (ICQService) ShortUserInfo added in v0.10.0

func (ICQService) XMLReqData added in v0.10.0

type ICQUserFinder added in v0.10.0

type ICQUserFinder interface {
	// FindByUIN returns a user with a matching UIN.
	FindByUIN(UIN uint32) (state.User, error)
	// FindByICQEmail returns a user with a matching email address.
	FindByICQEmail(email string) (state.User, error)
	// FindByICQName returns users with matching first name, last name, and
	// nickname. Empty values are not included in the search parameters.
	FindByICQName(firstName, lastName, nickName string) ([]state.User, error)
	// FindByICQInterests returns users who have at least one matching interest
	// for a given category code.
	FindByICQInterests(code uint16, keywords []string) ([]state.User, error)
	// FindByICQKeyword returns users with matching interest keyword across all
	// interest categories.
	FindByICQKeyword(keyword string) ([]state.User, error)
}

type ICQUserUpdater added in v0.10.0

type ICQUserUpdater interface {
	SetAffiliations(name state.IdentScreenName, data state.ICQAffiliations) error
	SetBasicInfo(name state.IdentScreenName, data state.ICQBasicInfo) error
	SetInterests(name state.IdentScreenName, data state.ICQInterests) error
	SetMoreInfo(name state.IdentScreenName, data state.ICQMoreInfo) error
	SetUserNotes(name state.IdentScreenName, data state.ICQUserNotes) error
	SetWorkInfo(name state.IdentScreenName, data state.ICQWorkInfo) error
}

type LocalBuddyListManager added in v0.14.0

type LocalBuddyListManager interface {
	AddBuddy(me state.IdentScreenName, them state.IdentScreenName) error
	RemoveBuddy(me state.IdentScreenName, them state.IdentScreenName) error
	DenyBuddy(me state.IdentScreenName, them state.IdentScreenName) error
	PermitBuddy(me state.IdentScreenName, them state.IdentScreenName) error
	RemoveDenyBuddy(me state.IdentScreenName, them state.IdentScreenName) error
	RemovePermitBuddy(me state.IdentScreenName, them state.IdentScreenName) error
	SetPDMode(user state.IdentScreenName, pdMode wire.FeedbagPDMode) error
}

type LocateService

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

LocateService provides functionality for the Locate food group, which is responsible for user profiles, user info lookups, directory information, and keyword lookups.

func NewLocateService

func NewLocateService(
	messageRelayer MessageRelayer,
	profileManager ProfileManager,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) LocateService

NewLocateService creates a new instance of LocateService.

func (LocateService) DirInfo added in v0.12.0

DirInfo returns directory information for a user.

func (LocateService) RightsQuery

func (s LocateService) RightsQuery(_ context.Context, inFrame wire.SNACFrame) wire.SNACMessage

RightsQuery returns SNAC wire.LocateRightsReply, which contains Locate food group settings for the current user.

func (LocateService) SetDirInfo

SetDirInfo sets directory information for current user (first name, last name, etc).

func (LocateService) SetInfo

SetInfo sets the user's profile, away message or capabilities.

func (LocateService) SetKeywordInfo

SetKeywordInfo sets profile keywords and interests. This method does nothing and exists to placate the AIM client. It returns wire.LocateSetKeywordReply with a canned success message.

func (LocateService) UserInfoQuery added in v0.2.0

UserInfoQuery fetches display information about an arbitrary user (not the current user). It returns wire.LocateUserInfoReply, which contains the profile, if requested, and/or the away message, if requested. This is a v2 of UserInfoQuery.

type MessageRelayer

type MessageRelayer interface {
	RelayToScreenNames(ctx context.Context, screenNames []state.IdentScreenName, msg wire.SNACMessage)
	RelayToScreenName(ctx context.Context, screenName state.IdentScreenName, msg wire.SNACMessage)
}

type ODirService added in v0.12.0

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

ODirService provides functionality for the ODir food group, which provides functionality for searching the user directory.

func NewODirService added in v0.12.0

func NewODirService(logger *slog.Logger, profileManager ProfileManager) ODirService

NewODirService creates a new instance of ODirService.

func (ODirService) InfoQuery added in v0.12.0

InfoQuery searches the user directory based on the query type: name/address, email, or interest. It dispatches the request to the appropriate search method and returns the search results or an error. The search type is determined by the presence of certain TLVs:

  • wire.ODirTLVEmailAddress: Search by email.
  • wire.ODirTLVInterest: Search by interest keyword.
  • wire.ODirTLVFirstName or wire.ODirTLVLastName: Search by name and address. First name or last name must be required to search by name and address.

AIM 5.x sends wire.ODirTLVSearchType to specify the search type. This TLV is ignored in order to be backwards compatible with older versions that do not send it. It doesn't appear to make a difference, since AIM 5.x sends the same TLV types for each search type.

func (ODirService) KeywordListQuery added in v0.12.0

func (s ODirService) KeywordListQuery(_ context.Context, inFrame wire.SNACFrame) (wire.SNACMessage, error)

KeywordListQuery returns a list of keywords that can be searched in the user directory.

type OServiceService

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

OServiceService provides functionality for the OService food group, which provides an assortment of services useful across multiple food groups.

func NewOServiceServiceForAdmin added in v0.9.0

func NewOServiceServiceForAdmin(
	cfg config.Config,
	logger *slog.Logger,
	messageRelayer MessageRelayer,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) *OServiceService

NewOServiceServiceForAdmin creates a new instance of OServiceService for Admin server.

func NewOServiceServiceForAlert added in v0.4.0

func NewOServiceServiceForAlert(
	cfg config.Config,
	logger *slog.Logger,
	messageRelayer MessageRelayer,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) *OServiceService

NewOServiceServiceForAlert creates a new instance of OServiceService for the Alert server.

func NewOServiceServiceForBART added in v0.7.0

func NewOServiceServiceForBART(
	cfg config.Config,
	logger *slog.Logger,
	messageRelayer MessageRelayer,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) *OServiceService

NewOServiceServiceForBART creates a new instance of OServiceService for the BART server.

func NewOServiceServiceForChatNav added in v0.3.0

func NewOServiceServiceForChatNav(
	cfg config.Config,
	logger *slog.Logger,
	messageRelayer MessageRelayer,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) *OServiceService

NewOServiceServiceForChatNav creates a new instance of OServiceService for ChatNav.

func NewOServiceServiceForODir added in v0.12.0

func NewOServiceServiceForODir(cfg config.Config, logger *slog.Logger) *OServiceService

NewOServiceServiceForODir creates a new instance of OServiceService for the ODir server.

func (OServiceService) ClientOnline added in v0.7.0

ClientOnline informs the server that the client is ready.

func (OServiceService) ClientVersions

ClientVersions informs the server what food group versions the client supports and returns to the client what food group versions it supports. This method simply regurgitates versions supplied by the client in inBody back to the client in a OServiceHostVersions SNAC. The server doesn't attempt to accommodate any particular food group version. The server implicitly accommodates any food group version for Windows AIM clients 5.x. It returns SNAC wire.OServiceHostVersions containing the server's supported food group versions.

func (OServiceService) HostOnline added in v0.7.0

func (s OServiceService) HostOnline() wire.SNACMessage

HostOnline initiates the Alert protocol sequence. It returns SNAC wire.OServiceHostOnline containing the list of food groups supported by the Alert service. Alert is provided by BOS in addition to the standalone Alert service. AIM 4.x always creates a secondary TCP connection for Alert, whereas 5.x can use the existing BOS connection for Alert services.

func (OServiceService) IdleNotification

IdleNotification sets the user idle time. Set session idle time to the value of bodyIn.IdleTime. Return a user arrival message to all users who have this user on their buddy list.

func (OServiceService) RateParamsQuery

func (s OServiceService) RateParamsQuery(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame) wire.SNACMessage

RateParamsQuery returns SNAC rate limits. It returns SNAC wire.OServiceRateParamsReply containing rate limits for all food groups supported by this server.

The purpose of this method is to convey per-SNAC server-side rate limits to the client. The response consists of two main parts: rate classes and rate groups. Rate classes define limits based on specific parameters, while rate groups associate these limits with relevant SNAC types.

The current implementation does not enforce server-side rate limiting. Instead, the provided values inform the client about the recommended client-side rate limits.

The rate limit values were taken from the example SNAC dump documented here: https://web.archive.org/web/20221207225518/https://wiki.nina.chat/wiki/Protocols/OSCAR/SNAC/OSERVICE_RATE_PARAMS_REPLY

AIM clients silently fail when they expect a rate limit rule that does not exist in this response. When support for a new food group is added to the server, update this function accordingly.

func (OServiceService) RateParamsSubAdd

RateParamsSubAdd exists to capture the SNAC input in unit tests to verify it's correctly unmarshalled.

func (OServiceService) ServiceRequest added in v0.7.0

func (OServiceService) SetPrivacyFlags added in v0.5.0

SetPrivacyFlags sets client privacy settings. Currently, there's no action to take when these flags are set. This method simply logs the flags set by the client.

func (OServiceService) SetUserInfoFields

SetUserInfoFields sets the user's visibility status to visible or invisible. The visibility status is set according to the inFrame TLV entry under key wire.OServiceUserInfoStatus. If the value is 0x0000, set invisible. If set to 0x0100, set invisible. Else, return an error for any other value. It returns SNAC wire.OServiceUserInfoUpdate containing the user's info.

func (OServiceService) UserInfoQuery

func (s OServiceService) UserInfoQuery(_ context.Context, sess *state.Session, inFrame wire.SNACFrame) wire.SNACMessage

UserInfoQuery returns SNAC wire.OServiceUserInfoUpdate containing the user's info.

type OServiceServiceForBOS

type OServiceServiceForBOS struct {
	OServiceService
	// contains filtered or unexported fields
}

OServiceServiceForBOS provides functionality for the OService food group running on the BOS server.

func NewOServiceServiceForBOS

func NewOServiceServiceForBOS(
	cfg config.Config,
	messageRelayer MessageRelayer,
	logger *slog.Logger,
	cookieIssuer CookieBaker,
	chatRoomManager ChatRoomRegistry,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) *OServiceServiceForBOS

NewOServiceServiceForBOS creates a new instance of OServiceServiceForBOS.

func (OServiceServiceForBOS) ClientOnline

ClientOnline runs when the current user is ready to join. It announces current user's arrival to users who have the current user on their buddy list.

func (OServiceServiceForBOS) ServiceRequest

ServiceRequest handles service discovery, providing a host name and metadata for connecting to the food group service specified in inFrame.

type OServiceServiceForChat

type OServiceServiceForChat struct {
	OServiceService
	// contains filtered or unexported fields
}

OServiceServiceForChat provides functionality for the OService food group running on the Chat server.

func NewOServiceServiceForChat

func NewOServiceServiceForChat(
	cfg config.Config,
	logger *slog.Logger,
	messageRelayer MessageRelayer,
	chatRoomManager ChatRoomRegistry,
	chatMessageRelayer ChatMessageRelayer,
	buddyListRetriever BuddyListRetriever,
	sessionRetriever SessionRetriever,
) *OServiceServiceForChat

NewOServiceServiceForChat creates a new instance of NewOServiceServiceForChat.

func (OServiceServiceForChat) ClientOnline

ClientOnline runs when the current user is ready to join the chat. Trigger the following actions:

  • Send current user the chat room metadata
  • Announce current user's arrival to other chat room participants
  • Send current user the chat room participant list

type OfflineMessageManager added in v0.10.0

type OfflineMessageManager interface {
	DeleteMessages(recip state.IdentScreenName) error
	RetrieveMessages(recip state.IdentScreenName) ([]state.OfflineMessage, error)
	SaveMessage(offlineMessage state.OfflineMessage) error
}

type PermitDenyService added in v0.5.0

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

PermitDenyService provides functionality for the PermitDeny (PD) food group. The PD food group manages settings for permit/deny (allow/block) for pre-feedbag (sever-side buddy list) AIM clients.

func NewPermitDenyService added in v0.5.0

func NewPermitDenyService(
	buddyListRetriever BuddyListRetriever,
	localBuddyListManager LocalBuddyListManager,
	messageRelayer MessageRelayer,
	sessionRetriever SessionRetriever,
) PermitDenyService

NewPermitDenyService creates an instance of PermitDenyService.

func (PermitDenyService) AddDenyListEntries added in v0.14.0

AddDenyListEntries adds users to your block list and sets your visibility mode to "deny some". If your screen name is passed as a single element in the input payload, your visibility mode is set to "permit all" instead. Your buddy list and your relations' buddy lists are updated to reflect the current mode.

func (PermitDenyService) AddPermListEntries added in v0.14.0

AddPermListEntries adds users to your permit list and sets your visibility mode to "permit some". If your screen name is passed as a single element in the input payload, your visibility mode is set to "deny all" instead. Your buddy list and your relations' buddy lists are updated to reflect the current mode.

func (PermitDenyService) DelDenyListEntries added in v0.14.0

DelDenyListEntries removes users from your deny list. Your buddy list and your relations' buddy lists are updated to reflect the list update.

func (PermitDenyService) DelPermListEntries added in v0.14.0

DelPermListEntries removes users from your permit list. Your buddy list and your relations' buddy lists are updated to reflect the list update.

func (PermitDenyService) RightsQuery added in v0.5.0

RightsQuery returns settings for the PermitDeny food group. It returns SNAC wire.PermitDenyRightsReply. The values in the return SNAC were arbitrarily chosen.

type ProfileManager

type ProfileManager interface {
	FindByAIMEmail(email string) (state.User, error)
	FindByAIMKeyword(keyword string) ([]state.User, error)
	FindByAIMNameAndAddr(info state.AIMNameAndAddr) ([]state.User, error)
	InterestList() ([]wire.ODirKeywordListItem, error)
	Profile(screenName state.IdentScreenName) (string, error)
	SetDirectoryInfo(name state.IdentScreenName, info state.AIMNameAndAddr) error
	SetKeywords(name state.IdentScreenName, keywords [5]string) error
	SetProfile(screenName state.IdentScreenName, body string) error
	User(screenName state.IdentScreenName) (*state.User, error)
}

type SessionRegistry added in v0.14.0

type SessionRegistry interface {
	AddSession(screenName state.DisplayScreenName) *state.Session
	RemoveSession(sess *state.Session)
}

type SessionRetriever added in v0.10.0

type SessionRetriever interface {
	RetrieveSession(screenName state.IdentScreenName) *state.Session
}

type UserLookupService added in v0.13.0

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

UserLookupService implements the UserLookup food group.

func NewUserLookupService added in v0.13.0

func NewUserLookupService(profileManager ProfileManager) UserLookupService

NewUserLookupService returns a new instance of UserLookupService.

func (UserLookupService) FindByEmail added in v0.13.0

FindByEmail searches for a user by email address.

type UserManager

type UserManager interface {
	User(screenName state.IdentScreenName) (*state.User, error)
	InsertUser(u state.User) error
}

Jump to

Keyboard shortcuts

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