fix: ensure `CommunityDescription` reprocessing on decryption failure

Previously, `CommunityDescription` instances failing partial decryption
were not reprocessed due to duplicate message check. This commit fixes
the issue by bypassing the check for such descriptions, allowing their
reprocessing upon receiving missing encryption key.

fixes: status-im/status-desktop#13647
This commit is contained in:
Patryk Osmaczko 2024-03-18 17:59:23 +01:00 committed by osmaczko
parent b9d9938209
commit 17c5ab414b
2 changed files with 19 additions and 5 deletions

View File

@ -1066,7 +1066,8 @@ func (o *Community) UpdateCommunityDescription(description *protobuf.CommunityDe
response := o.emptyCommunityChanges()
if description.Clock <= o.config.CommunityDescription.Clock {
// Enables processing of identical clocks. Identical descriptions may be reprocessed upon subsequent receipt of the previously missing encryption key.
if description.Clock < o.config.CommunityDescription.Clock {
return response, nil
}

View File

@ -3704,6 +3704,19 @@ func (m *Messenger) outputToCSV(timestamp uint32, messageID types.HexBytes, from
}
}
func (m *Messenger) shouldSkipDuplicate(messageType protobuf.ApplicationMetadataMessage_Type) bool {
// Permit re-processing of ApplicationMetadataMessage_COMMUNITY_DESCRIPTION messages,
// as they may be queued pending receipt of decryption keys.
allowedDuplicateTypes := map[protobuf.ApplicationMetadataMessage_Type]struct{}{
protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION: struct{}{},
}
if _, isAllowedDuplicate := allowedDuplicateTypes[messageType]; isAllowedDuplicate {
return false
}
return true
}
func (m *Messenger) handleImportedMessages(messagesToHandle map[transport.Filter][]*types.Message) error {
messageState := m.buildMessageState()
@ -3740,8 +3753,8 @@ func (m *Messenger) handleImportedMessages(messagesToHandle map[transport.Filter
if err != nil {
logger.Warn("failed to check message exists", zap.Error(err))
}
if exists {
logger.Debug("messageExists", zap.String("messageID", messageID))
if exists && m.shouldSkipDuplicate(msg.ApplicationLayer.Type) {
logger.Debug("skipping duplicate", zap.String("messageID", messageID))
continue
}
@ -3939,8 +3952,8 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
if err != nil {
logger.Warn("failed to check message exists", zap.Error(err))
}
if exists {
logger.Debug("messageExists", zap.String("messageID", messageID))
if exists && m.shouldSkipDuplicate(msg.ApplicationLayer.Type) {
logger.Debug("skipping duplicate", zap.String("messageID", messageID))
continue
}