Skip to content

Commit

Permalink
enhance and fix GetDialogs, GetMessages, GetHistory, added sleep thes…
Browse files Browse the repository at this point in the history
…holds for these methods, add Iter methods for each to return result via channel, bug fixes in cache missings, v1.4.8
  • Loading branch information
AmarnathCJD committed Dec 25, 2024
1 parent 44757c2 commit 5e00b5f
Show file tree
Hide file tree
Showing 4 changed files with 641 additions and 120 deletions.
10 changes: 7 additions & 3 deletions telegram/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ func (c *CACHE) UpdateUser(user *UserObj) bool {
c.Lock()
defer c.Unlock()

if _, ok := c.users[user.ID]; !ok {
c.users[user.ID] = user
}

if user.Min {
if userFromCache, ok := c.users[user.ID]; ok {
if userFromCache.Min {
Expand All @@ -432,14 +436,16 @@ func (c *CACHE) UpdateUser(user *UserObj) bool {
}

c.InputPeers.InputUsers[user.ID] = user.AccessHash
c.users[user.ID] = user
return true
}

func (c *CACHE) UpdateChannel(channel *Channel) bool {
c.Lock()
defer c.Unlock()

if _, ok := c.channels[channel.ID]; !ok {
c.channels[channel.ID] = channel
}
if currAccessHash, ok := c.InputPeers.InputChannels[channel.ID]; ok {
if activeCh, ok := c.channels[channel.ID]; ok {
if activeCh.Min {
Expand All @@ -462,9 +468,7 @@ func (c *CACHE) UpdateChannel(channel *Channel) bool {
return false
}

c.channels[channel.ID] = channel
c.InputPeers.InputChannels[channel.ID] = channel.AccessHash

return true
}

Expand Down
Loading

0 comments on commit 5e00b5f

Please sign in to comment.