To improve message reliability, we're adding an urgency flag to outgoing messages. For example, outgoing calls are urgent, but delivery receipts are not. [Android][] and [Desktop][] have already done this work. At a high level, I added an `isUrgent` property to `TSOutgoingMessage`s. It defaults to `true`. Some subclasses, like `OWSReceiptsForSenderMessage`, override it to return `false`. Builds off of a few other commits (not necessary to understand this commit, but might be useful for posterity): -e858a0d916-8c6d2ebe8c-402b117221-2ba0cd764d-266a4663e9-8e5009bbf7[Android]:dc04c8ed98[Desktop]:06190b1434
42 lines
1.4 KiB
Swift
42 lines
1.4 KiB
Swift
//
|
|
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
import XCTest
|
|
import SignalServiceKit
|
|
|
|
class OWSOutgoingReactionMessageTest: SSKBaseTestSwift {
|
|
private lazy var reactionMessage: OWSOutgoingReactionMessage = {
|
|
write { transaction in
|
|
let thread = TSContactThread.getOrCreateThread(
|
|
withContactAddress: SignalServiceAddress(phoneNumber: "+12223334444"),
|
|
transaction: transaction
|
|
)
|
|
|
|
let messageBuilder = TSOutgoingMessageBuilder.outgoingMessageBuilder(thread: thread, messageBody: nil)
|
|
messageBuilder.timestamp = 100
|
|
let message = messageBuilder.build(transaction: transaction)
|
|
|
|
return OWSOutgoingReactionMessage(
|
|
thread: thread,
|
|
message: message,
|
|
emoji: "🔮",
|
|
isRemoving: false,
|
|
expiresInSeconds: 1234,
|
|
transaction: transaction
|
|
)
|
|
}
|
|
}()
|
|
|
|
func testIsUrgent() throws {
|
|
XCTAssertTrue(reactionMessage.isUrgent)
|
|
}
|
|
|
|
func testShouldBeSaved() throws {
|
|
// Reactions should be saved, but their outgoing messages are not. For example,
|
|
// if I react with 🔮, we save that reaction, but we don't save the message that
|
|
// tells everyone about that reaction.
|
|
XCTAssertFalse(reactionMessage.shouldBeSaved)
|
|
}
|
|
}
|