From 9973321d13e56ccb50b68941009f2486009de3d0 Mon Sep 17 00:00:00 2001 From: Dmitriy Pominov <6616639+dpominov@users.noreply.github.com> Date: Thu, 13 Feb 2025 20:32:00 +0300 Subject: [PATCH] fix(peers): panic in peers.InmemoryCaches --- telegram/peers/memory_storage.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/telegram/peers/memory_storage.go b/telegram/peers/memory_storage.go index d439917893..a0510e9d8c 100644 --- a/telegram/peers/memory_storage.go +++ b/telegram/peers/memory_storage.go @@ -108,7 +108,7 @@ type InmemoryCache struct { func (f *InmemoryCache) SaveUsers(ctx context.Context, users ...*tg.User) error { f.usersMux.Lock() defer f.usersMux.Unlock() - if f.channelsFull == nil { + if f.users == nil { f.users = map[int64]*tg.User{} } @@ -123,7 +123,7 @@ func (f *InmemoryCache) SaveUsers(ctx context.Context, users ...*tg.User) error func (f *InmemoryCache) SaveUserFulls(ctx context.Context, users ...*tg.UserFull) error { f.usersFullMux.Lock() defer f.usersFullMux.Unlock() - if f.channelsFull == nil { + if f.usersFull == nil { f.usersFull = map[int64]*tg.UserFull{} } @@ -156,7 +156,7 @@ func (f *InmemoryCache) FindUserFull(ctx context.Context, id int64) (*tg.UserFul func (f *InmemoryCache) SaveChats(ctx context.Context, chats ...*tg.Chat) error { f.chatsMux.Lock() defer f.chatsMux.Unlock() - if f.channelsFull == nil { + if f.chats == nil { f.chats = map[int64]*tg.Chat{} } @@ -171,7 +171,7 @@ func (f *InmemoryCache) SaveChats(ctx context.Context, chats ...*tg.Chat) error func (f *InmemoryCache) SaveChatFulls(ctx context.Context, chats ...*tg.ChatFull) error { f.chatsFullMux.Lock() defer f.chatsFullMux.Unlock() - if f.channelsFull == nil { + if f.chatsFull == nil { f.chatsFull = map[int64]*tg.ChatFull{} } @@ -204,7 +204,7 @@ func (f *InmemoryCache) FindChatFull(ctx context.Context, id int64) (*tg.ChatFul func (f *InmemoryCache) SaveChannels(ctx context.Context, channels ...*tg.Channel) error { f.channelsMux.Lock() defer f.channelsMux.Unlock() - if f.channelsFull == nil { + if f.channels == nil { f.channels = map[int64]*tg.Channel{} }