From 781a2c7c8e64aa91b58d9d39d1c1be3ba7a281e5 Mon Sep 17 00:00:00 2001 From: Dario Gabriel Lipicar Date: Wed, 10 Jan 2024 02:04:49 -0300 Subject: [PATCH] fix: ensure needed community tokens are available in the db Fixes #13171 --- protocol/messenger_communities.go | 4 ++++ services/ext/service.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index 430ccd29d..ce91dc916 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -3667,6 +3667,10 @@ func (m *Messenger) RemoveCommunityToken(chainID int, contractAddress string) er return m.communitiesManager.RemoveCommunityToken(chainID, contractAddress) } +func (m *Messenger) FetchMissingCommunityTokens(community *communities.Community) error { + return m.communitiesManager.HandleCommunityTokensMetadata(community) +} + func (m *Messenger) CheckPermissionsToJoinCommunity(request *requests.CheckPermissionToJoinCommunity) (*communities.CheckPermissionToJoinResponse, error) { if err := request.Validate(); err != nil { return nil, err diff --git a/services/ext/service.go b/services/ext/service.go index 4db3e24a0..2e2862e66 100644 --- a/services/ext/service.go +++ b/services/ext/service.go @@ -674,6 +674,14 @@ func (s *Service) fetchCommunity(communityID string, fetchLatest bool) (*communi return nil, err } + if community != nil { + // Call this to ensure CommunityTokens are stored to DB + err = s.messenger.FetchMissingCommunityTokens(community) + if err != nil { + return nil, err + } + } + return community, nil }