github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/globals/globals.go (about) 1 package globals 2 3 import ( 4 "fmt" 5 "regexp" 6 7 "github.com/keybase/client/go/badges" 8 "github.com/keybase/client/go/chat/types" 9 "github.com/keybase/client/go/libkb" 10 "golang.org/x/net/context" 11 ) 12 13 var DefaultTeamTopic = "general" 14 var EmojiPattern = regexp.MustCompile(`(?::)([^:\s]+)(?::)`) 15 16 type ChatContext struct { 17 CtxFactory types.ContextFactory // source of verified user info and crypt keys 18 InboxSource types.InboxSource // source of remote inbox entries for chat 19 ConvSource types.ConversationSource // source of remote message bodies for chat 20 MessageDeliverer types.MessageDeliverer // background message delivery service 21 ServerCacheVersions types.ServerCacheVersions // server side versions for chat caches 22 RegexpSearcher types.RegexpSearcher // For searching chat messages in a conversation via regexp 23 Indexer types.Indexer // For searching chat messages in the entire inbox 24 Syncer types.Syncer // For syncing inbox with server 25 FetchRetrier types.FetchRetrier // For retrying failed fetch requests 26 ConvLoader types.ConvLoader // background conversation loader 27 PushHandler types.PushHandler // for handling push notifications from chat server 28 TeamChannelSource types.TeamChannelSource // source of all channels in a team 29 AttachmentURLSrv types.AttachmentURLSrv // source of URLs for loading attachments 30 EphemeralPurger types.EphemeralPurger // triggers background purges of ephemeral chats 31 ActivityNotifier types.ActivityNotifier // notify clients of chat of new activity 32 AttachmentUploader types.AttachmentUploader // upload attachments 33 NativeVideoHelper types.NativeVideoHelper // connection to native for doing things with video 34 StellarLoader types.StellarLoader // stellar payment/request loader 35 StellarSender types.StellarSender // stellar in-chat payment sender 36 StellarPushHandler types.OobmHandler 37 Unfurler types.Unfurler // unfurl messages with URLs 38 CommandsSource types.ConversationCommandsSource // source for / commands for conversations 39 CoinFlipManager types.CoinFlipManager // manage /flip games 40 JourneyCardManager types.JourneyCardManager // manages team journey cards 41 TeamMentionLoader types.TeamMentionLoader // load potential team mentions 42 ExternalAPIKeySource types.ExternalAPIKeySource // source of third party API keys 43 LiveLocationTracker types.LiveLocationTracker // track live location messages for updates 44 BotCommandManager types.BotCommandManager // manages commands from bots in convs 45 UIInboxLoader types.UIInboxLoader // manages loading inbox for UI 46 UIThreadLoader types.UIThreadLoader // manages loading threads for UI 47 Badger *badges.Badger // app badging 48 ParticipantsSource types.ParticipantSource // get team participants 49 EmojiSource types.EmojiSource // emoji support 50 EphemeralTracker types.EphemeralTracker // tracking of ephemeral msg caches 51 ArchiveRegistry types.ChatArchiveRegistry // Metadata store of chat archives 52 } 53 54 func (c *ChatContext) Describe() string { 55 return fmt.Sprintf(`ChatContext{ 56 CtxFactory: %v, 57 InboxSource: %v, 58 ConvSource: %v, 59 MessageDeliverer: %v, 60 ServerCacheVersions: %v, 61 RegexpSearcher: %v, 62 Indexer: %v, 63 Syncer: %v, 64 FetchRetrier: %v, 65 ConvLoader: %v, 66 PushHandler: %v, 67 TeamChannelSource: %v, 68 AttachmentURLSrv: %v, 69 EphemeralPurger: %v, 70 ActivityNotifier: %v, 71 AttachmentUploader: %v, 72 NativeVideoHelper: %v, 73 StellarLoader: %v, 74 StellarSender: %v, 75 StellarPushHandler: %v, 76 Unfurler: %v, 77 CommandsSource: %v, 78 CoinFlipManager: %v, 79 JourneyCardManager: %v, 80 TeamMentionLoader: %v, 81 ExternalAPIKeySource: %v, 82 LiveLocationTracker: %v, 83 BotCommandManager: %v, 84 UIInboxLoader: %v, 85 UIThreadLoader: %v, 86 Badger: %v, 87 ParticipantSource %v, 88 EmojiSource: %v 89 EphemeralTracker: %v 90 }`, 91 c.CtxFactory != nil, 92 c.InboxSource != nil, 93 c.ConvSource != nil, 94 c.MessageDeliverer != nil, 95 c.ServerCacheVersions != nil, 96 c.RegexpSearcher != nil, 97 c.Indexer != nil, 98 c.Syncer != nil, 99 c.FetchRetrier != nil, 100 c.ConvLoader != nil, 101 c.PushHandler != nil, 102 c.TeamChannelSource != nil, 103 c.AttachmentURLSrv != nil, 104 c.EphemeralPurger != nil, 105 c.ActivityNotifier != nil, 106 c.AttachmentUploader != nil, 107 c.NativeVideoHelper != nil, 108 c.StellarLoader != nil, 109 c.StellarSender != nil, 110 c.StellarPushHandler != nil, 111 c.Unfurler != nil, 112 c.CommandsSource != nil, 113 c.CoinFlipManager != nil, 114 c.JourneyCardManager != nil, 115 c.TeamMentionLoader != nil, 116 c.ExternalAPIKeySource != nil, 117 c.LiveLocationTracker != nil, 118 c.BotCommandManager != nil, 119 c.UIInboxLoader != nil, 120 c.UIThreadLoader != nil, 121 c.Badger != nil, 122 c.ParticipantsSource != nil, 123 c.EmojiSource != nil, 124 c.EphemeralTracker != nil, 125 ) 126 } 127 128 type Context struct { 129 *libkb.GlobalContext 130 *ChatContext 131 } 132 133 func (c *Context) ExternalG() *libkb.GlobalContext { 134 return c.GlobalContext 135 } 136 137 func NewContext(g *libkb.GlobalContext, c *ChatContext) *Context { 138 return &Context{ 139 GlobalContext: g, 140 ChatContext: c, 141 } 142 } 143 144 type Contextified struct { 145 gc *Context 146 } 147 148 func NewContextified(gc *Context) Contextified { 149 return Contextified{ 150 gc: gc, 151 } 152 } 153 154 func (c *Context) MetaContext(ctx context.Context) libkb.MetaContext { 155 return libkb.NewMetaContext(ctx, c.ExternalG()) 156 } 157 158 func (c Contextified) G() *Context { 159 return c.gc 160 } 161 162 func (c Contextified) MetaContext(ctx context.Context) libkb.MetaContext { 163 return libkb.NewMetaContext(ctx, c.G().ExternalG()) 164 } 165 166 type ChatContextified struct { 167 gc *ChatContext 168 } 169 170 func NewChatContextified(gc *ChatContext) ChatContextified { 171 return ChatContextified{ 172 gc: gc, 173 } 174 } 175 176 func (c ChatContextified) ChatG() *ChatContext { 177 return c.gc 178 }