Skip to content

fix: app sends large amount of last read messages - WPB-17439 #2968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ public extension ZMConversation {
_ content: MessageCapable,
in context: NSManagedObjectContext
) throws -> ZMClientMessage? {
guard let selfConversation = ZMConversation.fetchSelfMLSConversation(in: context) else {
let selfClient = ZMUser.selfUser(in: context).selfClient()
let hasRegisteredMLSClient = selfClient?.hasRegisteredMLSClient ?? false

guard
hasRegisteredMLSClient,
let selfConversation = ZMConversation.fetchSelfMLSConversation(in: context)
else {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import Foundation
@testable import WireDataModel
@testable import WireDataModelSupport

class ZMConversationTests_SelfConversation: ZMConversationTestsBase {

Expand All @@ -38,6 +39,11 @@ class ZMConversationTests_SelfConversation: ZMConversationTestsBase {
let proteusSelfConversation = try XCTUnwrap(ZMConversation.selfConversation(in: uiMOC))
let mlsSelfConversation = createMLSSelfConversation()

// Self client is an mls client
let selfClient = ModelHelper().createSelfClient(in: uiMOC)
selfClient.mlsPublicKeys = .init(ed25519: "somekey")
selfClient.needsToUploadMLSPublicKeys = false

// A conversation with a last read time stamp
let conversationID = UUID.create()
let lastReadTimestamp = Date(timeIntervalSince1970: 0)
Expand Down Expand Up @@ -85,6 +91,11 @@ class ZMConversationTests_SelfConversation: ZMConversationTestsBase {
let proteusSelfConversation = try XCTUnwrap(ZMConversation.selfConversation(in: uiMOC))
let mlsSelfConversation = createMLSSelfConversation()

// Self client is an mls client
let selfClient = ModelHelper().createSelfClient(in: uiMOC)
selfClient.mlsPublicKeys = .init(ed25519: "somekey")
selfClient.needsToUploadMLSPublicKeys = false

// A conversation with a cleared time stamp
let conversationID = UUID.create()
let clearedTimestamp = Date(timeIntervalSince1970: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ extension ClientMessageRequestStrategy: InsertedObjectSyncTranscoder {
typealias Object = ZMClientMessage

func insert(object: ZMClientMessage, completion: @escaping () -> Void) {
// Temp fix for avoiding to send a large amount of last read
// messages, see: [WPB-17439]
if
let conversation = object.conversation,
conversation.isSelfConversation,
conversation.messageProtocol == .mls {
completion()
return
}

let hasRegisteredMLSClient = context.performAndWait {
let selfClient = ZMUser.selfUser(in: context).selfClient()
return selfClient?.hasRegisteredMLSClient ?? false
Expand Down
Loading