diff --git a/telegram/handlers.go b/telegram/handlers.go index 0170d5e..66582a2 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -149,13 +149,13 @@ func (c *Client) updateHandler() { // new user discovered func (c *Client) updateUser(update *client.UpdateUser) { // check if MUC nicknames should be updated - cacheUser, ok := c.cache.GetUser(update.User.Id) - if ok && (cacheUser.FirstName != update.User.FirstName || cacheUser.LastName != update.User.LastName) { + oldCacheUser, ok := c.cache.GetUser(update.User.Id) + c.cache.SetUser(update.User.Id, update.User) + if ok && (oldCacheUser.FirstName != update.User.FirstName || oldCacheUser.LastName != update.User.LastName) { newNickname := c.GetMUCNickname(update.User.Id) c.updateMUCsNickname(update.User.Id, newNickname) } - c.cache.SetUser(update.User.Id, update.User) show, status, presenceType := c.userStatusToText(update.User.Status, update.User.Id) go c.ProcessStatusUpdate(update.User.Id, status, show, gateway.SPType(presenceType)) } diff --git a/telegram/utils.go b/telegram/utils.go index 34c0914..bfdf02d 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -890,6 +890,10 @@ func (c *Client) updateMUCsNickname(memberID int64, newNickname string) { for mucId, state := range c.mucCache { oldOccupant, ok := state.Occupants.Get(memberID) if ok { + c.DelayedStatusesLock.Lock() + delete(c.DelayedStatuses, mucId) + c.DelayedStatusesLock.Unlock() + deleted := state.Occupants.Set(memberID, &MUCOccupant{ Nickname: newNickname, Affiliation: oldOccupant.Affiliation,