Documentation
¶
Index ¶
- Variables
- type Friend
- type FriendStatus
- type Manager
- func (m *Manager) AcceptRequest(agentID, myName string, myPublicKey []byte) (*Friend, error)
- func (m *Manager) GetPendingRequests() []*Friend
- func (m *Manager) ListAcceptedFriends() []*Friend
- func (m *Manager) RejectRequest(agentID string) (*Friend, error)
- func (m *Manager) RevokeFriend(agentID string) error
- func (m *Manager) SendRequest(fromAgentID, fromAgentName string, publicKey []byte, message string) error
- type Store
- func (s *Store) AddFriend(f *Friend) error
- func (s *Store) Close()
- func (s *Store) GetFriend(agentID string) *Friend
- func (s *Store) IsFriend(agentID string) bool
- func (s *Store) ListFriends(status FriendStatus) []*Friend
- func (s *Store) RemoveFriend(agentID string) error
- func (s *Store) UpdateStatus(agentID string, status FriendStatus) error
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateRequest = errors.New("friend request already exists")
ErrDuplicateRequest is returned when a friend request already exists.
Functions ¶
This section is empty.
Types ¶
type Friend ¶
type Friend struct {
AgentID string `json:"agentId"`
AgentName string `json:"agentName"`
PublicKey []byte `json:"publicKey"`
Status FriendStatus `json:"status"`
AddedAt time.Time `json:"addedAt"`
UpdatedAt time.Time `json:"updatedAt"`
Message string `json:"message,omitempty"`
}
Friend represents a friend agent relationship.
type FriendStatus ¶
type FriendStatus string
FriendStatus represents the status of a friend relationship.
const ( StatusAny FriendStatus = "" StatusPending FriendStatus = "pending" StatusAccepted FriendStatus = "accepted" StatusRejected FriendStatus = "rejected" StatusRevoked FriendStatus = "revoked" )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles the friend request/response lifecycle.
func NewManager ¶
NewManager creates a new friend manager backed by the given store.
func (*Manager) AcceptRequest ¶
AcceptRequest accepts a pending friend request.
func (*Manager) GetPendingRequests ¶
GetPendingRequests returns all pending friend requests.
func (*Manager) ListAcceptedFriends ¶
ListAcceptedFriends returns all accepted friends.
func (*Manager) RejectRequest ¶
RejectRequest rejects a pending friend request.
func (*Manager) RevokeFriend ¶
RevokeFriend removes an accepted friend entirely.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages persistent friend relationships using SQLite.
func (*Store) Close ¶
func (s *Store) Close()
Close closes the underlying database connection. Safe to call multiple times.
func (*Store) ListFriends ¶
func (s *Store) ListFriends(status FriendStatus) []*Friend
ListFriends returns friends filtered by status. Use StatusAny to return all.
func (*Store) RemoveFriend ¶
RemoveFriend deletes a friend by agent ID. Returns os.ErrNotExist if not found.
func (*Store) UpdateStatus ¶
func (s *Store) UpdateStatus(agentID string, status FriendStatus) error
UpdateStatus changes the status of a friend. Returns os.ErrNotExist if not found.