github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/types/interfaces.go (about)

     1  package types
     2  
     3  import (
     4  	"io"
     5  	"os"
     6  	"regexp"
     7  	"time"
     8  
     9  	"github.com/keybase/client/go/badges"
    10  	"github.com/keybase/client/go/chat/s3"
    11  	"github.com/keybase/client/go/gregor"
    12  	"github.com/keybase/client/go/libkb"
    13  	"github.com/keybase/client/go/protocol/chat1"
    14  	"github.com/keybase/client/go/protocol/gregor1"
    15  	"github.com/keybase/client/go/protocol/keybase1"
    16  	"github.com/keybase/client/go/protocol/stellar1"
    17  	context "golang.org/x/net/context"
    18  )
    19  
    20  type Offlinable interface {
    21  	IsOffline(ctx context.Context) bool
    22  	Connected(ctx context.Context)
    23  	Disconnected(ctx context.Context)
    24  }
    25  
    26  type Resumable interface {
    27  	Start(ctx context.Context, uid gregor1.UID)
    28  	Stop(ctx context.Context) chan struct{}
    29  }
    30  
    31  type Suspendable interface {
    32  	Suspend(ctx context.Context) bool
    33  	Resume(ctx context.Context) bool
    34  }
    35  
    36  type BackgroundRunnable interface {
    37  	IsBackgroundActive() bool
    38  }
    39  
    40  type CryptKey interface {
    41  	Material() keybase1.Bytes32
    42  	Generation() int
    43  }
    44  
    45  type EphemeralCryptKey interface {
    46  	Material() keybase1.Bytes32
    47  	Generation() keybase1.EkGeneration
    48  }
    49  
    50  type AllCryptKeys map[chat1.ConversationMembersType][]CryptKey
    51  
    52  type NameInfoSource interface {
    53  	LookupID(ctx context.Context, name string, public bool) (NameInfo, error)
    54  	LookupName(ctx context.Context, tlfID chat1.TLFID, public bool, unverifiedTLFName string) (NameInfo, error)
    55  	AllCryptKeys(ctx context.Context, name string, public bool) (AllCryptKeys, error)
    56  	EncryptionKey(ctx context.Context, tlfName string, tlfID chat1.TLFID,
    57  		membersType chat1.ConversationMembersType, public bool, botUID *gregor1.UID) (CryptKey, NameInfo, error)
    58  	DecryptionKey(ctx context.Context, tlfName string, tlfID chat1.TLFID,
    59  		membersType chat1.ConversationMembersType, public bool,
    60  		keyGeneration int, kbfsEncrypted bool, botUID *gregor1.UID) (CryptKey, error)
    61  	EphemeralEncryptionKey(mctx libkb.MetaContext, tlfName string, tlfID chat1.TLFID,
    62  		membersType chat1.ConversationMembersType, public bool, botUID *gregor1.UID) (EphemeralCryptKey, error)
    63  	EphemeralDecryptionKey(mctx libkb.MetaContext, tlfName string, tlfID chat1.TLFID,
    64  		membersType chat1.ConversationMembersType, public bool, botUID *gregor1.UID,
    65  		generation keybase1.EkGeneration, contentCtime *gregor1.Time) (EphemeralCryptKey, error)
    66  	ShouldPairwiseMAC(ctx context.Context, tlfName string, tlfID chat1.TLFID,
    67  		membersType chat1.ConversationMembersType, public bool) (bool, []keybase1.KID, error)
    68  	TeamBotSettings(ctx context.Context, tlfName string, tlfID chat1.TLFID,
    69  		membersType chat1.ConversationMembersType, public bool) (map[keybase1.UserVersion]keybase1.TeamBotSettings, error)
    70  }
    71  
    72  type UnboxConversationInfo interface {
    73  	GetConvID() chat1.ConversationID
    74  	GetMembersType() chat1.ConversationMembersType
    75  	GetFinalizeInfo() *chat1.ConversationFinalizeInfo
    76  	GetExpunge() *chat1.Expunge
    77  	GetMaxDeletedUpTo() chat1.MessageID
    78  	IsPublic() bool
    79  	GetMaxMessage(chat1.MessageType) (chat1.MessageSummary, error)
    80  }
    81  
    82  type ConversationSource interface {
    83  	AcquireConversationLock(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID) error
    84  	ReleaseConversationLock(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID)
    85  
    86  	Push(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID,
    87  		msg chat1.MessageBoxed) (chat1.MessageUnboxed, bool, error)
    88  	PushUnboxed(ctx context.Context, conv UnboxConversationInfo,
    89  		uid gregor1.UID, msg []chat1.MessageUnboxed) error
    90  	Pull(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, reason chat1.GetThreadReason,
    91  		ri func() chat1.RemoteInterface, query *chat1.GetThreadQuery, pagination *chat1.Pagination) (chat1.ThreadView, error)
    92  	PullLocalOnly(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID,
    93  		reason chat1.GetThreadReason, query *chat1.GetThreadQuery, p *chat1.Pagination, maxPlaceholders int) (chat1.ThreadView, error)
    94  	PullFull(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, reason chat1.GetThreadReason,
    95  		query *chat1.GetThreadQuery, maxPages *int) (chat1.ThreadView, error)
    96  	GetMessage(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, msgID chat1.MessageID,
    97  		reason *chat1.GetThreadReason, ri func() chat1.RemoteInterface, resolveSupersedes bool) (chat1.MessageUnboxed, error)
    98  	GetMessages(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, msgIDs []chat1.MessageID,
    99  		reason *chat1.GetThreadReason, ri func() chat1.RemoteInterface, resolveSupersedes bool) ([]chat1.MessageUnboxed, error)
   100  	GetMessagesWithRemotes(ctx context.Context, conv chat1.Conversation, uid gregor1.UID,
   101  		msgs []chat1.MessageBoxed) ([]chat1.MessageUnboxed, error)
   102  	GetUnreadline(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID,
   103  		readMsgID chat1.MessageID) (*chat1.MessageID, error)
   104  	Clear(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, opts *ClearOpts) error
   105  	TransformSupersedes(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID,
   106  		msgs []chat1.MessageUnboxed, q *chat1.GetThreadQuery, superXform SupersedesTransform,
   107  		replyFiller ReplyFiller, maxDeletedUpTo *chat1.MessageID) ([]chat1.MessageUnboxed, error)
   108  	Expunge(ctx context.Context, conv UnboxConversationInfo, uid gregor1.UID, expunge chat1.Expunge) error
   109  	EphemeralPurge(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID,
   110  		purgeInfo *chat1.EphemeralPurgeInfo) (*chat1.EphemeralPurgeInfo, []chat1.MessageUnboxed, error)
   111  
   112  	SetRemoteInterface(func() chat1.RemoteInterface)
   113  	DeleteAssets(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, assets []chat1.Asset)
   114  }
   115  
   116  type MessageDeliverer interface {
   117  	Offlinable
   118  	Resumable
   119  
   120  	Queue(ctx context.Context, convID chat1.ConversationID, msg chat1.MessagePlaintext,
   121  		outboxID *chat1.OutboxID, sendOpts *chat1.SenderSendOptions,
   122  		prepareOpts *chat1.SenderPrepareOptions, identifyBehavior keybase1.TLFIdentifyBehavior) (chat1.OutboxRecord, error)
   123  	ForceDeliverLoop(ctx context.Context)
   124  	ActiveDeliveries(ctx context.Context) ([]chat1.OutboxRecord, error)
   125  	NextFailure() (chan []chat1.OutboxRecord, func())
   126  }
   127  
   128  type RegexpSearcher interface {
   129  	Search(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   130  		re *regexp.Regexp, uiCh chan chat1.ChatSearchHit, opts chat1.SearchOpts) ([]chat1.ChatSearchHit, []chat1.MessageUnboxed, error)
   131  }
   132  
   133  type Indexer interface {
   134  	Resumable
   135  	Suspendable
   136  	BackgroundRunnable
   137  
   138  	Search(ctx context.Context, query, origQuery string, opts chat1.SearchOpts,
   139  		hitUICh chan chat1.ChatSearchInboxHit, indexUICh chan chat1.ChatSearchIndexStatus) (*chat1.ChatSearchInboxResults, error)
   140  	// Add/update the index with the given messages
   141  	Add(ctx context.Context, convID chat1.ConversationID, msg []chat1.MessageUnboxed) error
   142  	// Remove the given messages from the index
   143  	Remove(ctx context.Context, convID chat1.ConversationID, msg []chat1.MessageUnboxed) error
   144  	// Clear search index data for the given user and conversation.
   145  	Clear(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID) error
   146  	FullyIndexed(ctx context.Context, convID chat1.ConversationID) (bool, error)
   147  	PercentIndexed(ctx context.Context, convID chat1.ConversationID) (int, error)
   148  	SearchableConvs(ctx context.Context, convID *chat1.ConversationID) ([]RemoteConversation, error)
   149  	OnDbNuke(mctx libkb.MetaContext) error
   150  	// For devel/testing
   151  	IndexInbox(ctx context.Context) (map[chat1.ConvIDStr]chat1.ProfileSearchConvStats, error)
   152  }
   153  
   154  type Sender interface {
   155  	Send(ctx context.Context, convID chat1.ConversationID, msg chat1.MessagePlaintext,
   156  		clientPrev chat1.MessageID, outboxID *chat1.OutboxID,
   157  		sendOpts *chat1.SenderSendOptions, prepareOpts *chat1.SenderPrepareOptions) (chat1.OutboxID, *chat1.MessageBoxed, error)
   158  	Prepare(ctx context.Context, msg chat1.MessagePlaintext, membersType chat1.ConversationMembersType,
   159  		conv *chat1.ConversationLocal, opts *chat1.SenderPrepareOptions) (SenderPrepareResult, error)
   160  }
   161  
   162  type InboxSource interface {
   163  	Offlinable
   164  	Resumable
   165  	Suspendable
   166  	badges.LocalChatState
   167  
   168  	Clear(ctx context.Context, uid gregor1.UID, opts *ClearOpts) error
   169  	Read(ctx context.Context, uid gregor1.UID, localizeTyp ConversationLocalizerTyp,
   170  		dataSource InboxSourceDataSourceTyp, maxLocalize *int, query *chat1.GetInboxLocalQuery) (Inbox, chan AsyncInboxResult, error)
   171  	ReadUnverified(ctx context.Context, uid gregor1.UID, dataSource InboxSourceDataSourceTyp,
   172  		query *chat1.GetInboxQuery) (Inbox, error)
   173  	Localize(ctx context.Context, uid gregor1.UID, convs []RemoteConversation,
   174  		localizeTyp ConversationLocalizerTyp) ([]chat1.ConversationLocal, chan AsyncInboxResult, error)
   175  	RemoteSetConversationStatus(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   176  		status chat1.ConversationStatus) error
   177  	RemoteDeleteConversation(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID) error
   178  	Search(ctx context.Context, uid gregor1.UID, query string, limit int,
   179  		emptyMode InboxSourceSearchEmptyMode) ([]RemoteConversation, error)
   180  	MarkAsRead(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID,
   181  		msgID *chat1.MessageID, forceUnread bool) error
   182  	Draft(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, text *string) error
   183  	NotifyUpdate(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID)
   184  	IncrementLocalConvVersion(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID) (*chat1.ConversationLocal, error)
   185  	MergeLocalMetadata(ctx context.Context, uid gregor1.UID, convs []chat1.ConversationLocal) error
   186  
   187  	Sync(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, convs []chat1.Conversation) (InboxSyncRes, error)
   188  	NewConversation(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers,
   189  		conv chat1.Conversation) error
   190  	IsMember(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID) (bool, error)
   191  	IsTeam(ctx context.Context, uid gregor1.UID, item string) (bool, error)
   192  	NewMessage(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, convID chat1.ConversationID,
   193  		msg chat1.MessageBoxed, maxMsgs []chat1.MessageSummary) (*chat1.ConversationLocal, error)
   194  	ReadMessage(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, convID chat1.ConversationID,
   195  		msgID chat1.MessageID) (*chat1.ConversationLocal, error)
   196  	SetStatus(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, convID chat1.ConversationID,
   197  		status chat1.ConversationStatus) (*chat1.ConversationLocal, error)
   198  	SetAppNotificationSettings(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers,
   199  		convID chat1.ConversationID, settings chat1.ConversationNotificationInfo) (*chat1.ConversationLocal, error)
   200  	TlfFinalize(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers,
   201  		convIDs []chat1.ConversationID, finalizeInfo chat1.ConversationFinalizeInfo) ([]chat1.ConversationLocal, error)
   202  	MembershipUpdate(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers,
   203  		joined []chat1.ConversationMember, removed []chat1.ConversationMember,
   204  		resets []chat1.ConversationMember, previews []chat1.ConversationID,
   205  		teamMemberRoleUpdate *chat1.TeamMemberRoleUpdate) (MembershipUpdateRes, error)
   206  	ConversationsUpdate(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers,
   207  		convUpdates []chat1.ConversationUpdate) error
   208  	TeamTypeChanged(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, convID chat1.ConversationID,
   209  		teamType chat1.TeamType) (*chat1.ConversationLocal, error)
   210  	UpgradeKBFSToImpteam(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers,
   211  		convID chat1.ConversationID) (*chat1.ConversationLocal, error)
   212  	Expunge(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, convID chat1.ConversationID,
   213  		expunge chat1.Expunge, maxMsgs []chat1.MessageSummary) (*chat1.ConversationLocal, error)
   214  	SetConvRetention(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, convID chat1.ConversationID,
   215  		policy chat1.RetentionPolicy) (*chat1.ConversationLocal, error)
   216  	SetTeamRetention(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, teamID keybase1.TeamID,
   217  		policy chat1.RetentionPolicy) ([]chat1.ConversationLocal, error)
   218  	SetConvSettings(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, convID chat1.ConversationID,
   219  		convSettings *chat1.ConversationSettings) (*chat1.ConversationLocal, error)
   220  	SubteamRename(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers, convIDs []chat1.ConversationID) ([]chat1.ConversationLocal, error)
   221  	UpdateInboxVersion(ctx context.Context, uid gregor1.UID, vers chat1.InboxVers) error
   222  
   223  	GetInboxQueryLocalToRemote(ctx context.Context,
   224  		lquery *chat1.GetInboxLocalQuery) (*chat1.GetInboxQuery, NameInfo, error)
   225  	UpdateLocalMtime(ctx context.Context, uid gregor1.UID, updates []chat1.LocalMtimeUpdate) error
   226  	TeamBotSettingsForConv(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID) (
   227  		map[keybase1.UID]keybase1.TeamBotSettings, error)
   228  
   229  	SetRemoteInterface(func() chat1.RemoteInterface)
   230  }
   231  
   232  type ServerCacheVersions interface {
   233  	Set(ctx context.Context, vers chat1.ServerCacheVers) error
   234  	MatchBodies(ctx context.Context, vers int) (int, error)
   235  	MatchInbox(ctx context.Context, vers int) (int, error)
   236  	Fetch(ctx context.Context) (chat1.ServerCacheVers, error)
   237  }
   238  
   239  type Syncer interface {
   240  	IsConnected(ctx context.Context) bool
   241  	Connected(ctx context.Context, cli chat1.RemoteInterface, uid gregor1.UID,
   242  		syncRes *chat1.SyncChatRes) error
   243  	Disconnected(ctx context.Context)
   244  	Sync(ctx context.Context, cli chat1.RemoteInterface, uid gregor1.UID,
   245  		syncRes *chat1.SyncChatRes) error
   246  	RegisterOfflinable(offlinable Offlinable)
   247  	SendChatStaleNotifications(ctx context.Context, uid gregor1.UID,
   248  		updates []chat1.ConversationStaleUpdate, immediate bool)
   249  	SelectConversation(ctx context.Context, convID chat1.ConversationID)
   250  	GetSelectedConversation() chat1.ConversationID
   251  	IsSelectedConversation(chat1.ConversationID) bool
   252  	Shutdown()
   253  }
   254  
   255  type RetryDescription interface {
   256  	Fix(ctx context.Context, uid gregor1.UID) error
   257  	SendStale(ctx context.Context, uid gregor1.UID)
   258  	String() string
   259  	RekeyFixable(ctx context.Context, tlfID chat1.TLFID) bool
   260  }
   261  
   262  type FetchRetrier interface {
   263  	Offlinable
   264  	Resumable
   265  
   266  	Failure(ctx context.Context, uid gregor1.UID, desc RetryDescription)
   267  	Success(ctx context.Context, uid gregor1.UID, desc RetryDescription)
   268  	Force(ctx context.Context)
   269  	Rekey(ctx context.Context, name string, membersType chat1.ConversationMembersType,
   270  		public bool)
   271  }
   272  
   273  type ConvLoader interface {
   274  	Resumable
   275  	Suspendable
   276  	BackgroundRunnable
   277  
   278  	Queue(ctx context.Context, job ConvLoaderJob) error
   279  }
   280  
   281  type OobmHandler interface {
   282  	HandleOobm(context.Context, gregor.OutOfBandMessage) (bool, error)
   283  }
   284  
   285  type PushHandler interface {
   286  	Resumable
   287  	TlfFinalize(context.Context, gregor.OutOfBandMessage) error
   288  	TlfResolve(context.Context, gregor.OutOfBandMessage) error
   289  	Activity(context.Context, gregor.OutOfBandMessage) error
   290  	Typing(context.Context, gregor.OutOfBandMessage) error
   291  	MembershipUpdate(context.Context, gregor.OutOfBandMessage) error
   292  	UpgradeKBFSToImpteam(ctx context.Context, m gregor.OutOfBandMessage) error
   293  	OobmHandler
   294  }
   295  
   296  type MobileAppState interface {
   297  	State() keybase1.MobileAppState
   298  	NextUpdate() chan keybase1.MobileAppState
   299  }
   300  
   301  type TeamChannelSource interface {
   302  	GetLastActiveForTLF(context.Context, gregor1.UID, chat1.TLFID, chat1.TopicType) (gregor1.Time, error)
   303  	GetLastActiveForTeams(context.Context, gregor1.UID, chat1.TopicType) (chat1.LastActiveTimeAll, error)
   304  	GetChannelsFull(context.Context, gregor1.UID, chat1.TLFID, chat1.TopicType) ([]chat1.ConversationLocal, error)
   305  	GetChannelsTopicName(ctx context.Context, uid gregor1.UID,
   306  		teamID chat1.TLFID, topicType chat1.TopicType) ([]chat1.ChannelNameMention, error)
   307  	GetChannelTopicName(ctx context.Context, uid gregor1.UID,
   308  		tlfID chat1.TLFID, topicType chat1.TopicType, convID chat1.ConversationID) (string, error)
   309  	GetRecentJoins(ctx context.Context, convID chat1.ConversationID, remoteClient chat1.RemoteInterface) (int, error)
   310  	GetLastActiveAt(ctx context.Context, teamID keybase1.TeamID, uid gregor1.UID, remoteClient chat1.RemoteInterface) (gregor1.Time, error)
   311  	OnLogout(libkb.MetaContext) error
   312  	OnDbNuke(libkb.MetaContext) error
   313  }
   314  
   315  type ActivityNotifier interface {
   316  	Activity(ctx context.Context, uid gregor1.UID, topicType chat1.TopicType, activity *chat1.ChatActivity,
   317  		source chat1.ChatActivitySource)
   318  	TypingUpdate(ctx context.Context, updates []chat1.ConvTypingUpdate)
   319  	JoinedConversation(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   320  		topicType chat1.TopicType, conv *chat1.InboxUIItem)
   321  	LeftConversation(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   322  		topicType chat1.TopicType)
   323  	ResetConversation(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   324  		topicType chat1.TopicType)
   325  	KBFSToImpteamUpgrade(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   326  		topicType chat1.TopicType)
   327  	SetConvRetention(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   328  		topicType chat1.TopicType, conv *chat1.InboxUIItem)
   329  	SetTeamRetention(ctx context.Context, uid gregor1.UID, teamID keybase1.TeamID,
   330  		topicType chat1.TopicType, convs []chat1.InboxUIItem)
   331  	SetConvSettings(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   332  		topicType chat1.TopicType, conv *chat1.InboxUIItem)
   333  	SubteamRename(ctx context.Context, uid gregor1.UID, convIDs []chat1.ConversationID,
   334  		topicType chat1.TopicType, convs []chat1.InboxUIItem)
   335  
   336  	InboxSyncStarted(ctx context.Context, uid gregor1.UID)
   337  	InboxSynced(ctx context.Context, uid gregor1.UID, topicType chat1.TopicType, syncRes chat1.ChatSyncResult)
   338  	InboxStale(ctx context.Context, uid gregor1.UID)
   339  	ThreadsStale(ctx context.Context, uid gregor1.UID, updates []chat1.ConversationStaleUpdate)
   340  
   341  	TLFFinalize(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, topicType chat1.TopicType,
   342  		finalizeInfo chat1.ConversationFinalizeInfo, conv *chat1.InboxUIItem)
   343  	TLFResolve(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, topicType chat1.TopicType,
   344  		resolveInfo chat1.ConversationResolveInfo)
   345  
   346  	AttachmentUploadStart(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   347  		outboxID chat1.OutboxID)
   348  	AttachmentUploadProgress(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   349  		outboxID chat1.OutboxID, bytesComplete, bytesTotal int64)
   350  
   351  	PromptUnfurl(ctx context.Context, uid gregor1.UID,
   352  		convID chat1.ConversationID, msgID chat1.MessageID, domain string)
   353  	ConvUpdate(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   354  		topicType chat1.TopicType, conv *chat1.InboxUIItem)
   355  }
   356  
   357  type IdentifyNotifier interface {
   358  	Reset()
   359  	ResetOnGUIConnect()
   360  	Send(ctx context.Context, update keybase1.CanonicalTLFNameAndIDWithBreaks)
   361  }
   362  
   363  type KeyFinder interface {
   364  	FindForEncryption(ctx context.Context, tlfName string, teamID chat1.TLFID,
   365  		membersType chat1.ConversationMembersType, public bool, botUID *gregor1.UID) (CryptKey, NameInfo, error)
   366  	FindForDecryption(ctx context.Context, tlfName string, teamID chat1.TLFID,
   367  		membersType chat1.ConversationMembersType, public bool, keyGeneration int,
   368  		kbfsEncrypted bool, botUID *gregor1.UID) (CryptKey, error)
   369  	EphemeralKeyForEncryption(mctx libkb.MetaContext, tlfName string, teamID chat1.TLFID,
   370  		membersType chat1.ConversationMembersType, public bool, botUID *gregor1.UID) (EphemeralCryptKey, error)
   371  	EphemeralKeyForDecryption(mctx libkb.MetaContext, tlfName string, teamID chat1.TLFID,
   372  		membersType chat1.ConversationMembersType, public bool, botUID *gregor1.UID,
   373  		generation keybase1.EkGeneration, contentCtime *gregor1.Time) (EphemeralCryptKey, error)
   374  	ShouldPairwiseMAC(ctx context.Context, tlfName string, teamID chat1.TLFID,
   375  		membersType chat1.ConversationMembersType, public bool) (bool, []keybase1.KID, error)
   376  	Reset()
   377  }
   378  
   379  type UPAKFinder interface {
   380  	LookupUsernameAndDevice(ctx context.Context, uid keybase1.UID, deviceID keybase1.DeviceID) (username libkb.NormalizedUsername, deviceName string, deviceType keybase1.DeviceTypeV2, err error)
   381  	CheckKIDForUID(ctx context.Context, uid keybase1.UID, kid keybase1.KID) (found bool, revokedAt *keybase1.KeybaseTime, deleted bool, err error)
   382  }
   383  
   384  type ContextFactory interface {
   385  	NewKeyFinder() KeyFinder
   386  	NewUPAKFinder() UPAKFinder
   387  }
   388  
   389  type ProgressReporter func(bytesCompleted, bytesTotal int64)
   390  
   391  type AttachmentFetcher interface {
   392  	DeleteAssets(ctx context.Context, convID chat1.ConversationID, assets []chat1.Asset,
   393  		ri func() chat1.RemoteInterface, signer s3.Signer) error
   394  	FetchAttachment(ctx context.Context, w io.Writer, convID chat1.ConversationID, asset chat1.Asset,
   395  		ri func() chat1.RemoteInterface, signer s3.Signer, progress ProgressReporter) error
   396  	StreamAttachment(ctx context.Context, convID chat1.ConversationID, asset chat1.Asset,
   397  		ri func() chat1.RemoteInterface, signer s3.Signer) (io.ReadSeeker, error)
   398  	PutUploadedAsset(ctx context.Context, filename string, asset chat1.Asset) error
   399  	IsAssetLocal(ctx context.Context, asset chat1.Asset) (bool, error)
   400  	OnDbNuke(mctx libkb.MetaContext) error
   401  	OnStart(mctx libkb.MetaContext)
   402  }
   403  
   404  type AttachmentURLSrv interface {
   405  	GetURL(ctx context.Context, convID chat1.ConversationID, msgID chat1.MessageID,
   406  		preview, noAnim, isEmoji bool) string
   407  	GetPendingPreviewURL(ctx context.Context, outboxID chat1.OutboxID) string
   408  	GetUnfurlAssetURL(ctx context.Context, convID chat1.ConversationID, asset chat1.Asset) string
   409  	GetGiphyURL(ctx context.Context, giphyURL string) string
   410  	GetGiphyGalleryURL(ctx context.Context, convID chat1.ConversationID,
   411  		tlfName string, results []chat1.GiphySearchResult) string
   412  	GetAttachmentFetcher() AttachmentFetcher
   413  	OnDbNuke(mctx libkb.MetaContext) error
   414  }
   415  
   416  type RateLimitedResult interface {
   417  	GetRateLimit() []chat1.RateLimit
   418  	SetRateLimits(rl []chat1.RateLimit)
   419  }
   420  
   421  type EphemeralPurger interface {
   422  	Resumable
   423  
   424  	Queue(ctx context.Context, purgeInfo chat1.EphemeralPurgeInfo) error
   425  }
   426  
   427  type AttachmentUploaderResultCb interface {
   428  	Wait() chan AttachmentUploadResult
   429  }
   430  
   431  type AttachmentUploader interface {
   432  	Register(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   433  		outboxID chat1.OutboxID, title, filename string, metadata []byte,
   434  		callerPreview *chat1.MakePreviewRes) (AttachmentUploaderResultCb, error)
   435  	Status(ctx context.Context, outboxID chat1.OutboxID) (AttachmentUploaderTaskStatus, AttachmentUploadResult, error)
   436  	Retry(ctx context.Context, outboxID chat1.OutboxID) (AttachmentUploaderResultCb, error)
   437  	Cancel(ctx context.Context, outboxID chat1.OutboxID) error
   438  	Complete(ctx context.Context, outboxID chat1.OutboxID)
   439  	GetUploadTempFile(ctx context.Context, outboxID chat1.OutboxID, filename string) (string, error)
   440  	GetUploadTempSink(ctx context.Context, filename string) (*os.File, chat1.OutboxID, error)
   441  	CancelUploadTempFile(ctx context.Context, outboxID chat1.OutboxID) error
   442  	OnDbNuke(mctx libkb.MetaContext) error
   443  }
   444  
   445  type NativeVideoHelper interface {
   446  	ThumbnailAndDuration(ctx context.Context, filename string) ([]byte, int, error)
   447  }
   448  
   449  type StellarLoader interface {
   450  	LoadPayment(ctx context.Context, convID chat1.ConversationID, msgID chat1.MessageID, senderUsername string, paymentID stellar1.PaymentID) *chat1.UIPaymentInfo
   451  	LoadRequest(ctx context.Context, convID chat1.ConversationID, msgID chat1.MessageID, senderUsername string, requestID stellar1.KeybaseRequestID) *chat1.UIRequestInfo
   452  }
   453  
   454  type StellarSender interface {
   455  	ParsePayments(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   456  		body string, replyTo *chat1.MessageID) []ParsedStellarPayment
   457  	DescribePayments(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   458  		payments []ParsedStellarPayment) (chat1.UIChatPaymentSummary, []ParsedStellarPayment, error)
   459  	DecorateWithPayments(ctx context.Context, body string, payments []chat1.TextPayment) string
   460  	SendPayments(ctx context.Context, convID chat1.ConversationID, payments []ParsedStellarPayment) ([]chat1.TextPayment, error)
   461  }
   462  
   463  type ConvConversationBackedStorage interface {
   464  	Put(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, name string, data interface{}) error
   465  	PutToKnownConv(ctx context.Context, uid gregor1.UID, conv chat1.ConversationLocal, data interface{}) error
   466  	Get(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, name string, res interface{},
   467  		createConvIfMissing bool) (bool, *chat1.ConversationLocal, error)
   468  	GetFromKnownConv(ctx context.Context, uid gregor1.UID, conv chat1.ConversationLocal, dest interface{}) (bool, error)
   469  }
   470  
   471  type UserConversationBackedStorage interface {
   472  	Put(ctx context.Context, uid gregor1.UID, name string, data interface{}) error
   473  	Get(ctx context.Context, uid gregor1.UID, name string, res interface{}) (bool, error)
   474  }
   475  
   476  type WhitelistExemption interface {
   477  	Use() bool
   478  	Matches(convID chat1.ConversationID, msgID chat1.MessageID, domain string) bool
   479  	Domain() string
   480  }
   481  
   482  type Unfurler interface {
   483  	UnfurlAndSend(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   484  		msg chat1.MessageUnboxed)
   485  	Prefetch(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, msgText string) int
   486  	Status(ctx context.Context, outboxID chat1.OutboxID) (UnfurlerTaskStatus, *chat1.UnfurlResult, error)
   487  	Retry(ctx context.Context, outboxID chat1.OutboxID)
   488  	Complete(ctx context.Context, outboxID chat1.OutboxID)
   489  
   490  	GetSettings(ctx context.Context, uid gregor1.UID) (chat1.UnfurlSettings, error)
   491  	SetSettings(ctx context.Context, uid gregor1.UID, settings chat1.UnfurlSettings) error
   492  	WhitelistAdd(ctx context.Context, uid gregor1.UID, domain string) error
   493  	WhitelistRemove(ctx context.Context, uid gregor1.UID, domain string) error
   494  	WhitelistAddExemption(ctx context.Context, uid gregor1.UID, exemption WhitelistExemption)
   495  	SetMode(ctx context.Context, uid gregor1.UID, mode chat1.UnfurlMode) error
   496  }
   497  
   498  type ConversationCommand interface {
   499  	Match(ctx context.Context, text string) bool
   500  	Execute(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, tlfName, text string,
   501  		replyTo *chat1.MessageID) error
   502  	Preview(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, tflName, text string)
   503  	Name() string
   504  	Usage() string
   505  	Description() string
   506  	HasHelpText() bool
   507  	Export() chat1.ConversationCommand
   508  }
   509  
   510  type ConversationCommandsSpec interface {
   511  	GetMembersType() chat1.ConversationMembersType
   512  	GetTeamType() chat1.TeamType
   513  	GetTopicName() string
   514  }
   515  
   516  type ConversationCommandsSource interface {
   517  	ListCommands(ctx context.Context, uid gregor1.UID, conv ConversationCommandsSpec) (chat1.ConversationCommandGroups, error)
   518  	GetBuiltins(ctx context.Context) []chat1.BuiltinCommandGroup
   519  	GetBuiltinCommandType(ctx context.Context, c ConversationCommandsSpec) chat1.ConversationBuiltinCommandTyp
   520  	AttemptBuiltinCommand(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   521  		tlfName string, body chat1.MessageBody, replyTo *chat1.MessageID) (bool, error)
   522  	PreviewBuiltinCommand(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   523  		tlfName, text string)
   524  }
   525  
   526  type CoinFlipManager interface {
   527  	Resumable
   528  	StartFlip(ctx context.Context, uid gregor1.UID, hostConvID chat1.ConversationID, tlfName, text string,
   529  		outboxID *chat1.OutboxID) error
   530  	MaybeInjectFlipMessage(ctx context.Context, boxedMsg chat1.MessageBoxed, inboxVers chat1.InboxVers,
   531  		uid gregor1.UID, convID chat1.ConversationID, topicType chat1.TopicType) bool
   532  	LoadFlip(ctx context.Context, uid gregor1.UID, hostConvID chat1.ConversationID, hostMsgID chat1.MessageID,
   533  		flipConvID chat1.ConversationID, gameID chat1.FlipGameID) (chan chat1.UICoinFlipStatus, chan error)
   534  	DescribeFlipText(ctx context.Context, text string) string
   535  	HasActiveGames(ctx context.Context) bool
   536  	IsFlipConversationCreated(ctx context.Context, outboxID chat1.OutboxID) (chat1.ConversationID, FlipSendStatus)
   537  }
   538  
   539  type TeamMentionLoader interface {
   540  	Resumable
   541  	LoadTeamMention(ctx context.Context, uid gregor1.UID,
   542  		maybeMention chat1.MaybeMention, knownTeamMentions []chat1.KnownTeamMention,
   543  		forceRemote bool) error
   544  	IsTeamMention(ctx context.Context, uid gregor1.UID,
   545  		maybeMention chat1.MaybeMention, knownTeamMentions []chat1.KnownTeamMention) bool
   546  }
   547  
   548  type ExternalAPIKeySource interface {
   549  	GetKey(ctx context.Context, typ chat1.ExternalAPIKeyTyp) (chat1.ExternalAPIKey, error)
   550  	GetAllKeys(ctx context.Context) ([]chat1.ExternalAPIKey, error)
   551  }
   552  
   553  type LiveLocationKey string
   554  
   555  type LiveLocationTracker interface {
   556  	Resumable
   557  	GetCurrentPosition(ctx context.Context, convID chat1.ConversationID, msgID chat1.MessageID)
   558  	StartTracking(ctx context.Context, convID chat1.ConversationID, msgID chat1.MessageID, endTime time.Time)
   559  	LocationUpdate(ctx context.Context, coord chat1.Coordinate)
   560  	GetCoordinates(ctx context.Context, key LiveLocationKey) []chat1.Coordinate
   561  	GetEndTime(ctx context.Context, key LiveLocationKey) *time.Time
   562  	ActivelyTracking(ctx context.Context) bool
   563  	StopAllTracking(ctx context.Context)
   564  }
   565  
   566  type BotCommandManager interface {
   567  	Resumable
   568  	Advertise(ctx context.Context, alias *string, ads []chat1.AdvertiseCommandsParam) error
   569  	Clear(ctx context.Context, filter *chat1.ClearBotCommandsFilter) error
   570  	PublicCommandsConv(ctx context.Context, username string) (*chat1.ConversationID, error)
   571  	ListCommands(ctx context.Context, convID chat1.ConversationID) ([]chat1.UserBotCommandOutput, map[string]string, error)
   572  	UpdateCommands(ctx context.Context, convID chat1.ConversationID, info *chat1.BotInfo) (chan error, error)
   573  }
   574  
   575  type SupersedesTransform interface {
   576  	Run(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID,
   577  		originalMsgs []chat1.MessageUnboxed, maxDeletedUpTo *chat1.MessageID) ([]chat1.MessageUnboxed, error)
   578  }
   579  
   580  type ReplyFiller interface {
   581  	Fill(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   582  		msgs []chat1.MessageUnboxed) ([]chat1.MessageUnboxed, error)
   583  }
   584  
   585  type UIInboxLoader interface {
   586  	Resumable
   587  	UpdateLayout(ctx context.Context, reselectMode chat1.InboxLayoutReselectMode, reason string)
   588  	UpdateLayoutFromNewMessage(ctx context.Context, conv RemoteConversation)
   589  	UpdateLayoutFromSubteamRename(ctx context.Context, convs []RemoteConversation)
   590  	UpdateLayoutFromSmallIncrease(ctx context.Context)
   591  	UpdateLayoutFromSmallReset(ctx context.Context)
   592  	UpdateConvs(ctx context.Context, convIDs []chat1.ConversationID) error
   593  	LoadNonblock(ctx context.Context, query *chat1.GetInboxLocalQuery, maxUnbox *int, skipUnverified bool) error
   594  }
   595  
   596  type UIThreadLoader interface {
   597  	Offlinable
   598  	LoadNonblock(ctx context.Context, chatUI libkb.ChatUI, uid gregor1.UID,
   599  		convID chat1.ConversationID, reason chat1.GetThreadReason, pgmode chat1.GetThreadNonblockPgMode,
   600  		cbmode chat1.GetThreadNonblockCbMode, knownRemotes []string, query *chat1.GetThreadQuery, uipagination *chat1.UIPagination) error
   601  	Load(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   602  		reason chat1.GetThreadReason, knownRemotes []string, query *chat1.GetThreadQuery,
   603  		pagination *chat1.Pagination) (chat1.ThreadView, error)
   604  }
   605  
   606  type JourneyCardManager interface {
   607  	Resumable
   608  	PickCard(context.Context, gregor1.UID, chat1.ConversationID, *chat1.ConversationLocal, *chat1.ThreadView) (*chat1.MessageUnboxedJourneycard, error)
   609  	SentMessage(context.Context, gregor1.UID, keybase1.TeamID, chat1.ConversationID) // Tell JourneyCardManager that the user has sent a message.
   610  	Dismiss(context.Context, gregor1.UID, keybase1.TeamID, chat1.ConversationID, chat1.JourneycardType)
   611  	OnDbNuke(libkb.MetaContext) error
   612  }
   613  
   614  type ParticipantSource interface {
   615  	Get(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   616  		dataSource InboxSourceDataSourceTyp) ([]gregor1.UID, error)
   617  	GetNonblock(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   618  		dataSource InboxSourceDataSourceTyp) chan ParticipantResult
   619  	GetWithNotifyNonblock(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   620  		dataSource InboxSourceDataSourceTyp)
   621  	GetParticipantsFromUids(ctx context.Context, uids []gregor1.UID) ([]chat1.ConversationLocalParticipant, error)
   622  }
   623  
   624  type EmojiSource interface {
   625  	Add(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, alias, filename string, allowOverwrite bool) (chat1.EmojiRemoteSource, error)
   626  	AddAlias(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
   627  		newAlias, existingAlias string) (chat1.EmojiRemoteSource, error)
   628  	Remove(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, alias string) error
   629  	Get(ctx context.Context, uid gregor1.UID, convID *chat1.ConversationID, opts chat1.EmojiFetchOpts) (chat1.UserEmojis, error)
   630  	Decorate(ctx context.Context, body string, uid gregor1.UID, messageType chat1.MessageType,
   631  		emojis []chat1.HarvestedEmoji) string
   632  	Harvest(ctx context.Context, body string, uid gregor1.UID, convID chat1.ConversationID,
   633  		mode EmojiHarvestMode) ([]chat1.HarvestedEmoji, error)
   634  	IsStockEmoji(alias string) bool
   635  	RemoteToLocalSource(ctx context.Context, uid gregor1.UID, remote chat1.EmojiRemoteSource) (chat1.EmojiLoadSource, chat1.EmojiLoadSource, error)
   636  	ToggleAnimations(ctx context.Context, uid gregor1.UID, enabled bool) error
   637  	IsValidSize(size int64) bool
   638  }
   639  
   640  type EphemeralTracker interface {
   641  	Resumable
   642  	GetAllPurgeInfo(ctx context.Context, uid gregor1.UID) ([]chat1.EphemeralPurgeInfo, error)
   643  	GetPurgeInfo(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID) (chat1.EphemeralPurgeInfo, error)
   644  	InactivatePurgeInfo(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID) error
   645  	SetPurgeInfo(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, purgeInfo *chat1.EphemeralPurgeInfo) error
   646  	MaybeUpdatePurgeInfo(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, purgeInfo *chat1.EphemeralPurgeInfo) error
   647  	Clear(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID) error
   648  	OnLogout(libkb.MetaContext) error
   649  	OnDbNuke(libkb.MetaContext) error
   650  }
   651  
   652  type PauseArchiveFn = func()
   653  type ChatArchiveRegistry interface {
   654  	Resumable
   655  
   656  	// List all known jobs
   657  	List(ctx context.Context) (res chat1.ArchiveChatListRes, err error)
   658  	// Get a job for a specific ID
   659  	Get(ctx context.Context, jobID chat1.ArchiveJobID) (res chat1.ArchiveChatJob, err error)
   660  	// Delete a jobs metadata, cancels it if it is currently running
   661  	Delete(ctx context.Context, jobID chat1.ArchiveJobID, deleteOutputPath bool) (err error)
   662  	// Sets (possibly updating) the job to the given state.
   663  	// cancel stops a running job by cancelling it's context and returns it's current state
   664  	Set(ctx context.Context, cancel PauseArchiveFn, job chat1.ArchiveChatJob) (err error)
   665  	// Stop a running job
   666  	Pause(ctx context.Context, jobID chat1.ArchiveJobID) (err error)
   667  	// Resume a paused job
   668  	Resume(ctx context.Context, jobID chat1.ArchiveJobID) (err error)
   669  	OnDbNuke(libkb.MetaContext) error
   670  }
   671  
   672  type ServerConnection interface {
   673  	Reconnect(context.Context) (bool, error)
   674  	GetClient() chat1.RemoteInterface
   675  }
   676  
   677  type InternalError interface {
   678  	// verbose error info for debugging but not user display
   679  	InternalError() string
   680  }
   681  
   682  type UnboxingError interface {
   683  	InternalError
   684  	Error() string
   685  	Inner() error
   686  	IsPermanent() bool
   687  	ExportType() chat1.MessageUnboxedErrorType
   688  	VersionKind() chat1.VersionKind
   689  	VersionNumber() int
   690  	IsCritical() bool
   691  	ToStatus() keybase1.Status
   692  }
   693  
   694  var _ error = (UnboxingError)(nil)