storage

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSecretUI = func() libkb.SecretUI { return SecretUI{} }

Functions

func CheckAndRecordBodyHash added in v1.0.19

func CheckAndRecordBodyHash(ctx context.Context, g *globals.Context, bodyHash chat1.Hash, uniqueMsgID chat1.MessageID, uniqueConvID chat1.ConversationID) error

CheckAndRecordBodyHash checks the current message's body hash against all the body hashes we've seen, to prevent replays. If the header hash is new, add it to the set.

func CheckAndRecordPrevPointer added in v1.0.19

func CheckAndRecordPrevPointer(ctx context.Context, g *globals.Context, msgID chat1.MessageID, convID chat1.ConversationID, uniqueHeaderHash chat1.Hash) error

CheckAndRecordPrevPointer checks the current message's header hash against all the prev pointers we've ever seen. If the current message is new, add it to the set.

func NewOutboxID added in v1.0.27

func NewOutboxID() (chat1.OutboxID, error)

Types

type AbortedError added in v1.0.46

type AbortedError struct{}

func NewAbortedError added in v1.0.46

func NewAbortedError() AbortedError

func (AbortedError) Error added in v1.0.46

func (e AbortedError) Error() string

func (AbortedError) Message added in v1.0.46

func (e AbortedError) Message() string

func (AbortedError) ShouldClear added in v1.0.46

func (e AbortedError) ShouldClear() bool

type AssetDeleter

type AssetDeleter interface {
	DeleteAssets(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, assets []chat1.Asset)
}

type BodyHashChecker added in v1.0.19

type BodyHashChecker func(bodyHash chat1.Hash, uniqueMsgID chat1.MessageID, uniqueConvID chat1.ConversationID) error

type ByCtimeOrder added in v1.0.19

type ByCtimeOrder []chat1.OutboxRecord

func (ByCtimeOrder) Len added in v1.0.19

func (a ByCtimeOrder) Len() int

func (ByCtimeOrder) Less added in v1.0.19

func (a ByCtimeOrder) Less(i, j int) bool

func (ByCtimeOrder) Swap added in v1.0.19

func (a ByCtimeOrder) Swap(i, j int)

type ByDatabaseOrder added in v1.0.19

type ByDatabaseOrder []types.RemoteConversation

func (ByDatabaseOrder) Len added in v1.0.19

func (a ByDatabaseOrder) Len() int

func (ByDatabaseOrder) Less added in v1.0.19

func (a ByDatabaseOrder) Less(i, j int) bool

func (ByDatabaseOrder) Swap added in v1.0.19

func (a ByDatabaseOrder) Swap(i, j int)

type DummyAssetDeleter

type DummyAssetDeleter struct{}

func (DummyAssetDeleter) DeleteAssets

func (d DummyAssetDeleter) DeleteAssets(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
	assets []chat1.Asset)

type Error added in v1.0.19

type Error interface {
	error
	ShouldClear() bool
	Message() string
}

type HoleyResultCollector added in v1.0.27

type HoleyResultCollector struct {
	ResultCollector
	// contains filtered or unexported fields
}

func NewHoleyResultCollector added in v1.0.27

func NewHoleyResultCollector(maxHoles int, rc ResultCollector) *HoleyResultCollector

func (*HoleyResultCollector) Holes added in v1.0.27

func (h *HoleyResultCollector) Holes() int

func (*HoleyResultCollector) PushPlaceholder added in v1.0.27

func (h *HoleyResultCollector) PushPlaceholder(msgID chat1.MessageID) bool

type Inbox added in v1.0.19

type Inbox struct {
	globals.Contextified

	utils.DebugLabeler
	// contains filtered or unexported fields
}

func NewInbox added in v1.0.19

func NewInbox(g *globals.Context, uid gregor1.UID) *Inbox

func (*Inbox) Clear added in v1.0.21

func (i *Inbox) Clear(ctx context.Context) (err Error)

func (*Inbox) Expunge added in v1.0.43

func (i *Inbox) Expunge(ctx context.Context, vers chat1.InboxVers,
	convID chat1.ConversationID, expunge chat1.Expunge, maxMsgs []chat1.MessageSummary) (err Error)

Mark the expunge on the stored inbox The inbox Expunge tag is kept up to date for retention but not for delete-history. Does not delete any messages. Relies on separate server mechanism to delete clear max messages.

func (*Inbox) GetConversation

func (i *Inbox) GetConversation(ctx context.Context, convID chat1.ConversationID) (res types.RemoteConversation, err Error)

func (*Inbox) MembershipUpdate added in v1.0.27

func (i *Inbox) MembershipUpdate(ctx context.Context, vers chat1.InboxVers,
	userJoined []chat1.Conversation, userRemoved []chat1.ConversationID,
	othersJoined []chat1.ConversationMember, othersRemoved []chat1.ConversationMember,
	userReset []chat1.ConversationID, othersReset []chat1.ConversationMember) (err Error)

func (*Inbox) Merge added in v1.0.19

func (i *Inbox) Merge(ctx context.Context, vers chat1.InboxVers, convsIn []chat1.Conversation,
	query *chat1.GetInboxQuery, p *chat1.Pagination) (err Error)

Merge add/updates conversations into the inbox. If a given conversation is either missing from the inbox, or is of greater version than what is currently stored, we write it down. Otherwise, we ignore it. If the inbox is currently blank, then we write down the given inbox version.

func (*Inbox) MergeLocalMetadata added in v1.0.33

func (i *Inbox) MergeLocalMetadata(ctx context.Context, convs []chat1.ConversationLocal) (err Error)

func (*Inbox) NewConversation added in v1.0.19

func (i *Inbox) NewConversation(ctx context.Context, vers chat1.InboxVers, conv chat1.Conversation) (err Error)

func (*Inbox) NewMessage added in v1.0.19

func (i *Inbox) NewMessage(ctx context.Context, vers chat1.InboxVers, convID chat1.ConversationID,
	msg chat1.MessageBoxed, maxMsgs []chat1.MessageSummary) (err Error)

func (*Inbox) Read added in v1.0.19

func (i *Inbox) Read(ctx context.Context, query *chat1.GetInboxQuery, p *chat1.Pagination) (vers chat1.InboxVers, res []types.RemoteConversation, pagination *chat1.Pagination, err Error)

func (*Inbox) ReadAll added in v1.0.19

func (i *Inbox) ReadAll(ctx context.Context) (vers chat1.InboxVers, res []types.RemoteConversation, err Error)

func (*Inbox) ReadMessage added in v1.0.19

func (i *Inbox) ReadMessage(ctx context.Context, vers chat1.InboxVers, convID chat1.ConversationID,
	msgID chat1.MessageID) (err Error)

func (*Inbox) ServerVersion added in v1.0.21

func (i *Inbox) ServerVersion(ctx context.Context) (vers int, err Error)

func (*Inbox) SetAppNotificationSettings added in v1.0.27

func (i *Inbox) SetAppNotificationSettings(ctx context.Context, vers chat1.InboxVers,
	convID chat1.ConversationID, settings chat1.ConversationNotificationInfo) (err Error)

func (*Inbox) SetConvRetention added in v1.0.41

func (i *Inbox) SetConvRetention(ctx context.Context, vers chat1.InboxVers,
	convID chat1.ConversationID, policy chat1.RetentionPolicy) (err Error)

func (*Inbox) SetStatus added in v1.0.19

func (i *Inbox) SetStatus(ctx context.Context, vers chat1.InboxVers, convID chat1.ConversationID,
	status chat1.ConversationStatus) (err Error)

func (*Inbox) SetTeamRetention added in v1.0.41

func (i *Inbox) SetTeamRetention(ctx context.Context, vers chat1.InboxVers,
	teamID keybase1.TeamID, policy chat1.RetentionPolicy) (res []chat1.ConversationID, err Error)

Update any local conversations with this team ID.

func (*Inbox) Sync added in v1.0.21

func (i *Inbox) Sync(ctx context.Context, vers chat1.InboxVers, convs []chat1.Conversation) (res InboxSyncRes, err Error)

func (*Inbox) TeamTypeChanged added in v1.0.30

func (i *Inbox) TeamTypeChanged(ctx context.Context, vers chat1.InboxVers,
	convID chat1.ConversationID, teamType chat1.TeamType, notifInfo *chat1.ConversationNotificationInfo) (err Error)

func (*Inbox) TlfFinalize added in v1.0.19

func (i *Inbox) TlfFinalize(ctx context.Context, vers chat1.InboxVers, convIDs []chat1.ConversationID,
	finalizeInfo chat1.ConversationFinalizeInfo) (err Error)

func (*Inbox) UpgradeKBFSToImpteam added in v1.0.41

func (i *Inbox) UpgradeKBFSToImpteam(ctx context.Context, vers chat1.InboxVers,
	convID chat1.ConversationID) (err Error)

func (*Inbox) Version added in v1.0.21

func (i *Inbox) Version(ctx context.Context) (vers chat1.InboxVers, err Error)

type InboxSyncRes added in v1.0.30

type InboxSyncRes struct {
	FilteredConvs      []types.RemoteConversation
	TeamTypeChanged    bool
	MembersTypeChanged []chat1.ConversationID
	Expunges           []InboxSyncResExpunge
	TopicNameChanged   []chat1.ConversationID
}

type InboxSyncResExpunge added in v1.0.43

type InboxSyncResExpunge struct {
	ConvID  chat1.ConversationID
	Expunge chat1.Expunge
}

type InboxVersionSource added in v1.0.27

type InboxVersionSource struct {
	globals.Contextified
}

func NewInboxVersionSource added in v1.0.27

func NewInboxVersionSource(g *globals.Context) *InboxVersionSource

func (*InboxVersionSource) GetInboxVersion added in v1.0.27

func (i *InboxVersionSource) GetInboxVersion(ctx context.Context, uid gregor1.UID) (chat1.InboxVers, error)

type InsatiableResultCollector added in v1.0.40

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

func NewInsatiableResultCollector added in v1.0.40

func NewInsatiableResultCollector() *InsatiableResultCollector

InsatiableResultCollector aggregates all messages all the way back. Its result can include holes.

func (*InsatiableResultCollector) Done added in v1.0.40

func (s *InsatiableResultCollector) Done() bool

func (*InsatiableResultCollector) Error added in v1.0.40

func (s *InsatiableResultCollector) Error(err Error) Error

func (*InsatiableResultCollector) Name added in v1.0.40

func (*InsatiableResultCollector) Push added in v1.0.40

func (*InsatiableResultCollector) PushPlaceholder added in v1.0.40

func (s *InsatiableResultCollector) PushPlaceholder(chat1.MessageID) bool

func (*InsatiableResultCollector) Result added in v1.0.40

func (*InsatiableResultCollector) String added in v1.0.40

func (s *InsatiableResultCollector) String() string

type InternalError added in v1.0.19

type InternalError struct {
	Msg string
}

func NewInternalError added in v1.0.19

func NewInternalError(ctx context.Context, d utils.DebugLabeler, msg string, args ...interface{}) InternalError

func (InternalError) Error added in v1.0.19

func (e InternalError) Error() string

func (InternalError) Message added in v1.0.19

func (e InternalError) Message() string

func (InternalError) ShouldClear added in v1.0.19

func (e InternalError) ShouldClear() bool

type MergeResult added in v1.0.40

type MergeResult struct {
	Expunged *chat1.Expunge
}

type MiscError added in v1.0.19

type MiscError struct {
	Msg string
}

func (MiscError) Error added in v1.0.19

func (e MiscError) Error() string

func (MiscError) Message added in v1.0.19

func (e MiscError) Message() string

func (MiscError) ShouldClear added in v1.0.19

func (e MiscError) ShouldClear() bool

type MissError added in v1.0.19

type MissError struct {
	Msg string
}

func (MissError) Error added in v1.0.19

func (e MissError) Error() string

func (MissError) Message added in v1.0.19

func (e MissError) Message() string

func (MissError) ShouldClear added in v1.0.19

func (e MissError) ShouldClear() bool

type Outbox added in v1.0.19

type Outbox struct {
	globals.Contextified

	utils.DebugLabeler
	// contains filtered or unexported fields
}

func NewOutbox added in v1.0.19

func NewOutbox(g *globals.Context, uid gregor1.UID) *Outbox

func (*Outbox) EphemeralPurge added in v1.0.48

func (o *Outbox) EphemeralPurge(ctx context.Context) (err error)

EphemeralPurge is called periodically to ensure exploding messages don't hang out too long in the outbox (since they are not encrypted with ephemeral keys until they leave it). Currently we purge anything that is in the error state and has been in the outbox for > ephemeralPurgeCutoff minutes.

func (*Outbox) GetUID added in v1.0.19

func (o *Outbox) GetUID() gregor1.UID

func (*Outbox) MarkAllAsError

func (o *Outbox) MarkAllAsError(ctx context.Context, errRec chat1.OutboxStateError) (res []chat1.OutboxRecord, err error)

func (*Outbox) MarkAsError added in v1.0.19

func (o *Outbox) MarkAsError(ctx context.Context, obr chat1.OutboxRecord, errRec chat1.OutboxStateError) (res chat1.OutboxRecord, err error)

MarkAsError will either mark an existing record as an error, or it will add the passed record as an error with the specified error state

func (*Outbox) PullAllConversations added in v1.0.19

func (o *Outbox) PullAllConversations(ctx context.Context, includeErrors bool, remove bool) ([]chat1.OutboxRecord, error)

PullAllConversations grabs all outbox entries for the current outbox, and optionally deletes them from storage

func (*Outbox) PushMessage added in v1.0.19

func (o *Outbox) PushMessage(ctx context.Context, convID chat1.ConversationID,
	msg chat1.MessagePlaintext, suppliedOutboxID *chat1.OutboxID,
	identifyBehavior keybase1.TLFIdentifyBehavior) (rec chat1.OutboxRecord, err Error)

func (*Outbox) RecordFailedAttempt added in v1.0.19

func (o *Outbox) RecordFailedAttempt(ctx context.Context, oldObr chat1.OutboxRecord) error

RecordFailedAttempt will either modify an existing matching record (if sending) to next attempt number, or if the record doesn't exist it adds it in.

func (*Outbox) RemoveMessage added in v1.0.19

func (o *Outbox) RemoveMessage(ctx context.Context, obid chat1.OutboxID) error

func (*Outbox) RetryMessage added in v1.0.19

func (o *Outbox) RetryMessage(ctx context.Context, obid chat1.OutboxID,
	identifyBehavior *keybase1.TLFIdentifyBehavior) error

func (*Outbox) SetClock added in v1.0.19

func (o *Outbox) SetClock(cl clockwork.Clock)

func (*Outbox) SprinkleIntoThread added in v1.0.19

func (o *Outbox) SprinkleIntoThread(ctx context.Context, convID chat1.ConversationID,
	thread *chat1.ThreadView) error

type PrevChecker added in v1.0.19

type PrevChecker func(msgID chat1.MessageID, convID chat1.ConversationID, uniqueHeaderHash chat1.Hash) error

type RemoteError added in v1.0.19

type RemoteError struct {
	Msg string
}

func (RemoteError) Error added in v1.0.19

func (e RemoteError) Error() string

func (RemoteError) Message added in v1.0.19

func (e RemoteError) Message() string

func (RemoteError) ShouldClear added in v1.0.19

func (e RemoteError) ShouldClear() bool

type ResultCollector added in v1.0.21

type ResultCollector interface {
	Push(msg chat1.MessageUnboxed)
	PushPlaceholder(msgID chat1.MessageID) bool
	Done() bool
	Result() []chat1.MessageUnboxed
	Error(err Error) Error
	Name() string

	String() string
}

type SecretUI added in v1.0.21

type SecretUI struct {
}

func (SecretUI) GetPassphrase added in v1.0.21

func (d SecretUI) GetPassphrase(pinentry keybase1.GUIEntryArg, terminal *keybase1.SecretEntryArg) (keybase1.GetPassphraseRes, error)

type ServerVersions added in v1.0.21

type ServerVersions struct {
	globals.Contextified
	utils.DebugLabeler
	// contains filtered or unexported fields
}

func NewServerVersions added in v1.0.21

func NewServerVersions(g *globals.Context) *ServerVersions

func (*ServerVersions) Fetch added in v1.0.21

func (*ServerVersions) MatchBodies added in v1.0.21

func (s *ServerVersions) MatchBodies(ctx context.Context, vers int) (int, error)

func (*ServerVersions) MatchInbox added in v1.0.21

func (s *ServerVersions) MatchInbox(ctx context.Context, vers int) (int, error)

func (*ServerVersions) Set added in v1.0.21

func (s *ServerVersions) Set(ctx context.Context, vers chat1.ServerCacheVers) (err error)

type SimpleResultCollector added in v1.0.21

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

SimpleResultCollector aggregates all results in a basic way. It is not thread safe.

func NewSimpleResultCollector added in v1.0.21

func NewSimpleResultCollector(num int) *SimpleResultCollector

func (*SimpleResultCollector) Done added in v1.0.21

func (s *SimpleResultCollector) Done() bool

func (*SimpleResultCollector) Error added in v1.0.21

func (s *SimpleResultCollector) Error(err Error) Error

func (*SimpleResultCollector) Name added in v1.0.21

func (s *SimpleResultCollector) Name() string

func (*SimpleResultCollector) Push added in v1.0.21

func (*SimpleResultCollector) PushPlaceholder added in v1.0.27

func (s *SimpleResultCollector) PushPlaceholder(chat1.MessageID) bool

func (*SimpleResultCollector) Result added in v1.0.21

func (*SimpleResultCollector) String added in v1.0.21

func (s *SimpleResultCollector) String() string

type Storage

type Storage struct {
	globals.Contextified
	utils.DebugLabeler
	// contains filtered or unexported fields
}

func New

func New(g *globals.Context, assetDeleter AssetDeleter) *Storage

func (*Storage) ClearAll

func (s *Storage) ClearAll(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID) (err Error)

func (*Storage) ClearBefore added in v1.0.48

func (s *Storage) ClearBefore(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID,
	upto chat1.MessageID) (err Error)

ClearBefore clears all messages up to (but not including) the upto messageID

func (*Storage) EphemeralPurge added in v1.0.48

func (s *Storage) EphemeralPurge(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, purgeInfo *chat1.EphemeralPurgeInfo) (newPurgeInfo *chat1.EphemeralPurgeInfo, explodedMsgs []chat1.MessageUnboxed, err Error)

For a given conversation, purge all ephemeral messages from purgeInfo.MinUnexplodedID to the present, updating bookkeeping for the next time we need to purge this conv.

func (*Storage) Expunge added in v1.0.43

func (s *Storage) Expunge(ctx context.Context,
	convID chat1.ConversationID, uid gregor1.UID, expunge chat1.Expunge) (res MergeResult, err Error)

func (*Storage) Fetch

func (s *Storage) Fetch(ctx context.Context, conv chat1.Conversation,
	uid gregor1.UID, rc ResultCollector, query *chat1.GetThreadQuery, pagination *chat1.Pagination) (res chat1.ThreadView, err Error)

func (*Storage) FetchMessages added in v1.0.19

func (s *Storage) FetchMessages(ctx context.Context, convID chat1.ConversationID,
	uid gregor1.UID, msgIDs []chat1.MessageID) (res []*chat1.MessageUnboxed, err Error)

func (*Storage) FetchUpToLocalMaxMsgID added in v1.0.19

func (s *Storage) FetchUpToLocalMaxMsgID(ctx context.Context,
	convID chat1.ConversationID, uid gregor1.UID, rc ResultCollector, iboxMaxMsgID chat1.MessageID,
	query *chat1.GetThreadQuery, pagination *chat1.Pagination) (res chat1.ThreadView, err Error)

func (*Storage) GetAllPurgeInfo added in v1.0.48

func (s *Storage) GetAllPurgeInfo(ctx context.Context, uid gregor1.UID) (allPurgeInfo map[string]chat1.EphemeralPurgeInfo, err error)

func (*Storage) GetMaxMsgID added in v1.0.19

func (s *Storage) GetMaxMsgID(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID) (chat1.MessageID, error)

func (*Storage) IsTLFIdentifyBroken added in v1.0.19

func (s *Storage) IsTLFIdentifyBroken(ctx context.Context, tlfID chat1.TLFID) bool

func (*Storage) MaybeNuke

func (s *Storage) MaybeNuke(ctx context.Context, force bool, err Error, convID chat1.ConversationID,
	uid gregor1.UID) Error

func (*Storage) Merge

func (s *Storage) Merge(ctx context.Context,
	convID chat1.ConversationID, uid gregor1.UID, msgs []chat1.MessageUnboxed) (res MergeResult, err Error)

Merge requires msgs to be sorted by descending message ID

func (*Storage) MergeHelper added in v1.0.43

func (s *Storage) MergeHelper(ctx context.Context,
	convID chat1.ConversationID, uid gregor1.UID, msgs []chat1.MessageUnboxed, expunge *chat1.Expunge) (res MergeResult, err Error)

MergeHelper requires msgs to be sorted by descending message ID expunge is optional

func (*Storage) ResultCollectorFromQuery added in v1.0.27

func (s *Storage) ResultCollectorFromQuery(ctx context.Context, query *chat1.GetThreadQuery,
	pagination *chat1.Pagination) ResultCollector

func (*Storage) SetAssetDeleter

func (s *Storage) SetAssetDeleter(assetDeleter AssetDeleter)

func (*Storage) SetClock added in v1.0.48

func (s *Storage) SetClock(clock clockwork.Clock)

func (*Storage) UpdateTLFIdentifyBreak added in v1.0.19

func (s *Storage) UpdateTLFIdentifyBreak(ctx context.Context, tlfID chat1.TLFID,
	breaks []keybase1.TLFIdentifyFailure) error

type TypedResultCollector added in v1.0.21

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

TypedResultCollector aggregates results with a type constraints. It is not thread safe.

func NewTypedResultCollector added in v1.0.21

func NewTypedResultCollector(num int, typs []chat1.MessageType) *TypedResultCollector

func (*TypedResultCollector) Done added in v1.0.21

func (t *TypedResultCollector) Done() bool

func (*TypedResultCollector) Error added in v1.0.21

func (t *TypedResultCollector) Error(err Error) Error

func (*TypedResultCollector) Name added in v1.0.21

func (t *TypedResultCollector) Name() string

func (*TypedResultCollector) Push added in v1.0.21

func (*TypedResultCollector) PushPlaceholder added in v1.0.27

func (t *TypedResultCollector) PushPlaceholder(msgID chat1.MessageID) bool

func (*TypedResultCollector) Result added in v1.0.21

func (*TypedResultCollector) String added in v1.0.21

func (t *TypedResultCollector) String() string

type VersionMismatchError added in v1.0.19

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

func NewVersionMismatchError added in v1.0.19

func NewVersionMismatchError(oldVers chat1.InboxVers, newVers chat1.InboxVers) VersionMismatchError

func (VersionMismatchError) Error added in v1.0.19

func (e VersionMismatchError) Error() string

func (VersionMismatchError) Message added in v1.0.19

func (e VersionMismatchError) Message() string

func (VersionMismatchError) ShouldClear added in v1.0.19

func (e VersionMismatchError) ShouldClear() bool

Jump to

Keyboard shortcuts

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