Documentation
¶
Overview ¶
Package chat is the local roster and per-peer linear log for AID-to-AID messaging. It has no network of its own.
Index ¶
- Constants
- Variables
- func DecodeNonce(s string) ([]byte, error)
- func EncodeEmpty() []byte
- func EncodeInvite(inv Invite) ([]byte, error)
- func EncodeMsg(m Msg) ([]byte, error)
- func EncodePull(after uint64) ([]byte, error)
- func NonceB64(nonce []byte) string
- func TruncateRunes(s string, n int) string
- func VerifyInvite(from, to a2al.Address, inv Invite, nowTS int64) bool
- type Invite
- type Msg
- type Pull
- type Rec
- type RosterEntry
- type Store
- func (s *Store) AppendIn(peer a2al.Address, rec Rec) (dup bool, unreadEdge bool, err error)
- func (s *Store) AppendOut(peer a2al.Address, rec Rec) (uint64, error)
- func (s *Store) Block(peer a2al.Address) error
- func (s *Store) CanSend(peer a2al.Address) bool
- func (s *Store) Contacts() []RosterEntry
- func (s *Store) Delete(peer a2al.Address) error
- func (s *Store) DingFresh(peer a2al.Address) bool
- func (s *Store) Get(peer a2al.Address) (RosterEntry, bool)
- func (s *Store) InPendingCount() int
- func (s *Store) Len(peer a2al.Address) int
- func (s *Store) MarkRead(peer a2al.Address, scannedTo uint64) error
- func (s *Store) MarkSent(peer a2al.Address, seq uint64) error
- func (s *Store) MaxInSeq(peer a2al.Address) uint64
- func (s *Store) PutInPending(peer a2al.Address, note string) error
- func (s *Store) PutOutPending(peer a2al.Address) error
- func (s *Store) Read(peer a2al.Address, after uint64, limit int) (out []Rec, scannedTo uint64, hasMore bool)
- func (s *Store) ReadCursor(peer a2al.Address) uint64
- func (s *Store) SetMutual(peer a2al.Address) error
- func (s *Store) SetNow(fn func() time.Time)
- func (s *Store) TotalUnread() int
- func (s *Store) TouchDing(peer a2al.Address) error
- func (s *Store) UnreadCount(peer a2al.Address) int
- func (s *Store) Unsent(peer a2al.Address) []Rec
Constants ¶
View Source
const ( StateOutPending = "out_pending" StateInPending = "in_pending" StateMutual = "mutual" StateBlocked = "blocked" DirOut = "out" DirIn = "in" StatusLocal = "local" StatusSent = "sent" StatusIn = "in" KindText = "text" KindFile = "file" PendingCap = 32 IgnoreTTL = 72 * time.Hour DingMerge = time.Hour NoteMaxRunes = 80 DefaultLimit = 50 PurposeInvite = "chat.invite" PowMaxAge = 24 * time.Hour )
View Source
const ( KindInvite = "chat.invite" KindAccept = "chat.accept" KindRefuse = "chat.refuse" KindDing = "chat.ding" KindPull = "chat.pull" KindMsg = "chat.msg" MsgText = "t" MsgFile = "f" )
Variables ¶
View Source
var ( ErrSelf = errors.New("chat: cannot message this identity") ErrNotFriends = errors.New("not_friends: the peer is not on this identity's chat list — call chat_request first") ErrAlready = errors.New("chat: already requested or friends") ErrBlocked = errors.New("chat: this peer is blocked") ErrNotPending = errors.New("chat: no pending invite from that peer") ErrPendingFull = errors.New("chat: pending invite list is full") ErrHasInbound = errors.New("chat: inbound invite already pending") ErrBadState = errors.New("chat: invalid roster state") ErrSignaling = errors.New("chat: signaling not delivered") )
View Source
var ErrTooLarge = errors.New("chat: message too large")
Functions ¶
func DecodeNonce ¶
func EncodeEmpty ¶
func EncodeEmpty() []byte
func EncodeInvite ¶
func EncodePull ¶
func TruncateRunes ¶
Types ¶
type Invite ¶
type Invite struct {
TS int64 `json:"ts"`
Nonce string `json:"nonce"`
Bits int `json:"bits"`
Note string `json:"note,omitempty"`
}
func DecodeInvite ¶
type Msg ¶
type Msg struct {
Seq uint64 `json:"seq"`
TS int64 `json:"ts"`
K string `json:"k"`
Body string `json:"body,omitempty"`
Ref string `json:"ref,omitempty"`
Name string `json:"name,omitempty"`
Size int64 `json:"size,omitempty"`
Author string `json:"author,omitempty"`
Grant string `json:"grant,omitempty"`
Sig string `json:"sig,omitempty"`
}
func MsgFromRec ¶
type Rec ¶
type RosterEntry ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Contacts ¶
func (s *Store) Contacts() []RosterEntry
func (*Store) InPendingCount ¶
func (*Store) TotalUnread ¶
Click to show internal directories.
Click to hide internal directories.