mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 04:07:07 +00:00
Fix MUC member nickname changes
This commit is contained in:
parent
623af72cdd
commit
983c0102a4
2 changed files with 7 additions and 3 deletions
|
|
@ -149,13 +149,13 @@ func (c *Client) updateHandler() {
|
||||||
// new user discovered
|
// new user discovered
|
||||||
func (c *Client) updateUser(update *client.UpdateUser) {
|
func (c *Client) updateUser(update *client.UpdateUser) {
|
||||||
// check if MUC nicknames should be updated
|
// check if MUC nicknames should be updated
|
||||||
cacheUser, ok := c.cache.GetUser(update.User.Id)
|
oldCacheUser, ok := c.cache.GetUser(update.User.Id)
|
||||||
if ok && (cacheUser.FirstName != update.User.FirstName || cacheUser.LastName != update.User.LastName) {
|
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)
|
newNickname := c.GetMUCNickname(update.User.Id)
|
||||||
c.updateMUCsNickname(update.User.Id, newNickname)
|
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)
|
show, status, presenceType := c.userStatusToText(update.User.Status, update.User.Id)
|
||||||
go c.ProcessStatusUpdate(update.User.Id, status, show, gateway.SPType(presenceType))
|
go c.ProcessStatusUpdate(update.User.Id, status, show, gateway.SPType(presenceType))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -890,6 +890,10 @@ func (c *Client) updateMUCsNickname(memberID int64, newNickname string) {
|
||||||
for mucId, state := range c.mucCache {
|
for mucId, state := range c.mucCache {
|
||||||
oldOccupant, ok := state.Occupants.Get(memberID)
|
oldOccupant, ok := state.Occupants.Get(memberID)
|
||||||
if ok {
|
if ok {
|
||||||
|
c.DelayedStatusesLock.Lock()
|
||||||
|
delete(c.DelayedStatuses, mucId)
|
||||||
|
c.DelayedStatusesLock.Unlock()
|
||||||
|
|
||||||
deleted := state.Occupants.Set(memberID, &MUCOccupant{
|
deleted := state.Occupants.Set(memberID, &MUCOccupant{
|
||||||
Nickname: newNickname,
|
Nickname: newNickname,
|
||||||
Affiliation: oldOccupant.Affiliation,
|
Affiliation: oldOccupant.Affiliation,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue