diff --git a/pkg/connector/backfill.go b/pkg/connector/backfill.go index 5c0714b..9470527 100644 --- a/pkg/connector/backfill.go +++ b/pkg/connector/backfill.go @@ -69,7 +69,7 @@ func (dc *DiscordClient) FetchMessages(ctx context.Context, fetchParams bridgev2 // Update our user cache with all of the users present in the response. This // indirectly makes `GetUserInfo` on `DiscordClient` return the information // we've fetched above. - cachedDiscordUserIDs := dc.userCache.HandleMessages(msgs) + cachedDiscordUserIDs := dc.userCache.UpdateWithMessages(msgs) { log := zerolog.Ctx(ctx).With(). diff --git a/pkg/connector/client.go b/pkg/connector/client.go index 4d2daac..6e92af8 100644 --- a/pkg/connector/client.go +++ b/pkg/connector/client.go @@ -132,7 +132,7 @@ func (cl *DiscordClient) connect(ctx context.Context) error { // Populate the user cache with the users from the READY payload. log.Debug().Int("n_users", len(cl.Session.State.Ready.Users)).Msg("Inserting users from READY into cache") - cl.userCache.HandleReady(&cl.Session.State.Ready) + cl.userCache.UpdateWithReady(&cl.Session.State.Ready) cl.BeginSyncing(ctx) diff --git a/pkg/connector/handlediscord.go b/pkg/connector/handlediscord.go index a4ba6bb..377f8c7 100644 --- a/pkg/connector/handlediscord.go +++ b/pkg/connector/handlediscord.go @@ -189,7 +189,7 @@ func (d *DiscordClient) handleDiscordEvent(rawEvt any) { switch evt := rawEvt.(type) { case *discordgo.Ready: log.Info().Msg("Received READY dispatch from discordgo") - d.userCache.HandleReady(evt) + d.userCache.UpdateWithReady(evt) d.UserLogin.BridgeState.Send(status.BridgeState{ StateEvent: status.StateConnected, }) @@ -207,11 +207,11 @@ func (d *DiscordClient) handleDiscordEvent(rawEvt any) { Msg("Dropping message that lacks an author") return } - d.userCache.HandleMessage(evt.Message) + d.userCache.UpdateWithMessage(evt.Message) wrappedEvt := d.wrapDiscordMessage(evt) d.UserLogin.Bridge.QueueRemoteEvent(d.UserLogin, &wrappedEvt) case *discordgo.UserUpdate: - d.userCache.HandleUserUpdate(evt) + d.userCache.UpdateWithUserUpdate(evt) case *discordgo.MessageReactionAdd: wrappedEvt := d.wrapDiscordReaction(evt.MessageReaction, true) d.UserLogin.Bridge.QueueRemoteEvent(d.UserLogin, &wrappedEvt) diff --git a/pkg/connector/usercache.go b/pkg/connector/usercache.go index 79ce5d2..881b737 100644 --- a/pkg/connector/usercache.go +++ b/pkg/connector/usercache.go @@ -46,7 +46,7 @@ func NewUserCache(session *discordgo.Session) *UserCache { } } -func (uc *UserCache) HandleReady(ready *discordgo.Ready) { +func (uc *UserCache) UpdateWithReady(ready *discordgo.Ready) { if ready == nil { return } @@ -59,25 +59,25 @@ func (uc *UserCache) HandleReady(ready *discordgo.Ready) { } } -// HandleMessage updates the user cache with the users involved in a single +// UpdateWithMessage updates the user cache with the users involved in a single // message (author, mentioned, mentioned author, etc.) // // The updated user IDs are returned. -func (uc *UserCache) HandleMessage(msg *discordgo.Message) []string { +func (uc *UserCache) UpdateWithMessage(msg *discordgo.Message) []string { if msg == nil { return []string{} } // For now just forward to HandleMessages until a need for a specialized // path makes itself known. - return uc.HandleMessages([]*discordgo.Message{msg}) + return uc.UpdateWithMessages([]*discordgo.Message{msg}) } -// HandleMessages updates the user cache with the total set of users involved +// UpdateWithMessages updates the user cache with the total set of users involved // with multiple messages (authors, mentioned users, mentioned authors, etc.) // // The updated user IDs are returned. -func (uc *UserCache) HandleMessages(msgs []*discordgo.Message) []string { +func (uc *UserCache) UpdateWithMessages(msgs []*discordgo.Message) []string { if len(msgs) == 0 { return []string{} } @@ -110,7 +110,7 @@ func (uc *UserCache) HandleMessages(msgs []*discordgo.Message) []string { return slices.Collect(maps.Keys(collectedUsers)) } -func (uc *UserCache) HandleUserUpdate(update *discordgo.UserUpdate) { +func (uc *UserCache) UpdateWithUserUpdate(update *discordgo.UserUpdate) { if update == nil || update.User == nil { return }