Dropping messages which shouldn't be processed without a thread
Removed an extra localised string value
This commit is contained in:
parent
a9afb2d1d1
commit
6685dc0572
|
@ -549,9 +549,10 @@ final class ConversationVC: BaseVC, SessionUtilRespondingViewController, Convers
|
|||
if
|
||||
viewModel.threadData.threadIsNoteToSelf == false &&
|
||||
viewModel.threadData.threadShouldBeVisible == false &&
|
||||
!SessionUtil.conversationVisibleInConfig(
|
||||
!SessionUtil.conversationInConfig(
|
||||
threadId: threadId,
|
||||
threadVariant: viewModel.threadData.threadVariant
|
||||
threadVariant: viewModel.threadData.threadVariant,
|
||||
visibleOnly: true
|
||||
)
|
||||
{
|
||||
Storage.shared.writeAsync { db in
|
||||
|
|
|
@ -407,7 +407,6 @@
|
|||
"MESSAGE_REQUESTS_NOTIFICATION" = "شما درخواست پیام جدیدی دارید";
|
||||
"TXT_HIDE_TITLE" = "پنهان کردن";
|
||||
"TXT_DELETE_ACCEPT" = "پذیرفتن";
|
||||
"TXT_DECLINE_TITLE" = "رد کردن";
|
||||
"TXT_BLOCK_USER_TITLE" = "مسدود کردن کاربر";
|
||||
"ALERT_ERROR_TITLE" = "خطا";
|
||||
"modal_call_permission_request_title" = "دسترسی تلفن مورد نیاز است";
|
||||
|
|
|
@ -345,6 +345,8 @@ public class SessionCell: UITableViewCell {
|
|||
titleTextField.textAlignment = (info.title?.textAlignment ?? .left)
|
||||
titleTextField.placeholder = info.title?.editingPlaceholder
|
||||
titleTextField.isHidden = (info.title == nil)
|
||||
titleTextField.accessibilityIdentifier = info.accessibility?.identifier
|
||||
titleTextField.accessibilityLabel = info.accessibility?.label
|
||||
subtitleLabel.isUserInteractionEnabled = (info.subtitle?.interaction == .copy)
|
||||
subtitleLabel.font = info.subtitle?.font
|
||||
subtitleLabel.text = info.subtitle?.text
|
||||
|
|
|
@ -163,6 +163,26 @@ public extension Message {
|
|||
}
|
||||
}
|
||||
|
||||
static func requiresExistingConversation(message: Message, threadVariant: SessionThread.Variant) -> Bool {
|
||||
switch threadVariant {
|
||||
case .contact, .community: return false
|
||||
|
||||
case .legacyGroup:
|
||||
switch message {
|
||||
case let controlMessage as ClosedGroupControlMessage:
|
||||
switch controlMessage.kind {
|
||||
case .new: return false
|
||||
default: return true
|
||||
}
|
||||
|
||||
default: return true
|
||||
}
|
||||
|
||||
case .group:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
static func shouldSync(message: Message) -> Bool {
|
||||
switch message {
|
||||
case is VisibleMessage: return true
|
||||
|
|
|
@ -20,13 +20,14 @@ public enum MessageReceiverError: LocalizedError {
|
|||
case invalidGroupPublicKey
|
||||
case noGroupKeyPair
|
||||
case invalidSharedConfigMessageHandling
|
||||
case requiredThreadNotInConfig
|
||||
|
||||
public var isRetryable: Bool {
|
||||
switch self {
|
||||
case .duplicateMessage, .duplicateMessageNewSnode, .duplicateControlMessage,
|
||||
.invalidMessage, .unknownMessage, .unknownEnvelopeType, .invalidSignature,
|
||||
.noData, .senderBlocked, .noThread, .selfSend, .decryptionFailed,
|
||||
.invalidSharedConfigMessageHandling:
|
||||
.invalidSharedConfigMessageHandling, .requiredThreadNotInConfig:
|
||||
return false
|
||||
|
||||
default: return true
|
||||
|
@ -54,7 +55,8 @@ public enum MessageReceiverError: LocalizedError {
|
|||
case .invalidGroupPublicKey: return "Invalid group public key."
|
||||
case .noGroupKeyPair: return "Missing group key pair."
|
||||
|
||||
case .invalidSharedConfigMessageHandling: return "Invalid handling of a shared config message"
|
||||
case .invalidSharedConfigMessageHandling: return "Invalid handling of a shared config message."
|
||||
case .requiredThreadNotInConfig: return "Required thread not in config."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,6 +185,13 @@ public enum MessageReceiver {
|
|||
associatedWithProto proto: SNProtoContent,
|
||||
dependencies: SMKDependencies = SMKDependencies()
|
||||
) throws {
|
||||
// Check if the message requires an existing conversation (if it does and the conversation isn't in
|
||||
// the config then the message will be dropped)
|
||||
guard
|
||||
!Message.requiresExistingConversation(message: message, threadVariant: threadVariant) ||
|
||||
SessionUtil.conversationInConfig(threadId: threadId, threadVariant: threadVariant, visibleOnly: false)
|
||||
else { throw MessageReceiverError.requiredThreadNotInConfig }
|
||||
|
||||
switch message {
|
||||
case let message as ReadReceipt:
|
||||
try MessageReceiver.handleReadReceipt(
|
||||
|
|
|
@ -298,9 +298,10 @@ internal extension SessionUtil {
|
|||
// MARK: - External Outgoing Changes
|
||||
|
||||
public extension SessionUtil {
|
||||
static func conversationVisibleInConfig(
|
||||
static func conversationInConfig(
|
||||
threadId: String,
|
||||
threadVariant: SessionThread.Variant
|
||||
threadVariant: SessionThread.Variant,
|
||||
visibleOnly: Bool
|
||||
) -> Bool {
|
||||
// FIXME: Remove this once `useSharedUtilForUserConfig` is permanent
|
||||
guard SessionUtil.userConfigsEnabled else { return true }
|
||||
|
@ -327,7 +328,7 @@ public extension SessionUtil {
|
|||
/// If the user opens a conversation with an existing contact but doesn't send them a message
|
||||
/// then the one-to-one conversation should remain hidden so we want to delete the `SessionThread`
|
||||
/// when leaving the conversation
|
||||
return SessionUtil.shouldBeVisible(priority: contact.priority)
|
||||
return (!visibleOnly || SessionUtil.shouldBeVisible(priority: contact.priority))
|
||||
|
||||
case .community:
|
||||
let maybeUrlInfo: OpenGroupUrlInfo? = Storage.shared
|
||||
|
|
Loading…
Reference in New Issue