Skip to content

Commit

Permalink
Ignore incoming typing notifications from logged-in users
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jun 14, 2023
1 parent 67c8d92 commit cf640ac
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ func (br *DiscordBridge) GetUserByID(id string) *User {
return user
}

func (br *DiscordBridge) GetCachedUserByID(id string) *User {
br.usersLock.Lock()
defer br.usersLock.Unlock()
return br.usersByID[id]
}

func (br *DiscordBridge) NewUser(dbUser *database.User) *User {
user := &User{
User: dbUser,
Expand Down Expand Up @@ -1228,10 +1234,17 @@ func (user *User) messageAckHandler(m *discordgo.MessageAck) {
}

func (user *User) typingStartHandler(t *discordgo.TypingStart) {
if t.UserID == user.DiscordID {
return
}
portal := user.GetExistingPortalByID(t.ChannelID)
if portal == nil || portal.MXID == "" {
return
}
targetUser := user.bridge.GetCachedUserByID(t.UserID)
if targetUser != nil {
return
}
portal.handleDiscordTyping(t)
}

Expand Down

0 comments on commit cf640ac

Please sign in to comment.