Bug fix old requests to join prematurely stop sync community handling (#2421)

This commit is contained in:
Samuel Hawksby-Robinson 2021-11-11 16:37:04 +00:00 committed by GitHub
parent 38cc695753
commit 87d7c48e2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -19,6 +19,8 @@ type Persistence struct {
logger *zap.Logger
}
var ErrOldRequestToJoin = errors.New("old request to join")
const communitiesBaseQuery = `SELECT c.id, c.private_key, c.description,c.joined,c.verified,c.muted,r.clock FROM communities_communities c LEFT JOIN communities_requests_to_join r ON c.id = r.community_id AND r.public_key = ?`
func (p *Persistence) SaveCommunity(community *Community) error {
@ -260,7 +262,7 @@ func (p *Persistence) SaveRequestToJoin(request *RequestToJoin) (err error) {
// This is already processed
if clock >= request.Clock {
return errors.New("old request to join")
return ErrOldRequestToJoin
}
_, err = tx.Exec(`INSERT INTO communities_requests_to_join(id,public_key,clock,ens_name,chat_id,community_id,state) VALUES (?, ?, ?, ?, ?, ?, ?)`, request.ID, request.PublicKey, request.Clock, request.ENSName, request.ChatID, request.CommunityID, request.State)

View File

@ -950,7 +950,7 @@ func (m *Messenger) handleSyncCommunity(messageState *ReceivedMessageState, sync
}
err = m.communitiesManager.SaveRequestToJoin(req)
if err != nil {
if err != nil && err != communities.ErrOldRequestToJoin {
logger.Debug("m.communitiesManager.SaveRequestToJoin error", zap.Error(err))
return err
}