diff --git a/Sources/ChatFeature/ViewModels/GroupChatViewModel.swift b/Sources/ChatFeature/ViewModels/GroupChatViewModel.swift index aa1dbefc8ed34f582d84df609d70b65631c69013..fc7a30d47a4cfef4ba89ea28fa89a5cc7cfd12ad 100644 --- a/Sources/ChatFeature/ViewModels/GroupChatViewModel.swift +++ b/Sources/ChatFeature/ViewModels/GroupChatViewModel.swift @@ -103,7 +103,13 @@ final class GroupChatViewModel { return "[DELETED]" } - return (contact.nickname ?? contact.username) ?? "Fetching username..." + var name = (contact.nickname ?? contact.username) ?? "Fetching username..." + + if contact.isBlocked { + name = "\(name) (Blocked)" + } + + return name } func didRequestReply(_ message: Message) { diff --git a/Sources/ChatListFeature/ViewModel/ChatListViewModel.swift b/Sources/ChatListFeature/ViewModel/ChatListViewModel.swift index 470e9cf33f728211be5c5f9dae5d9bca9647ac5f..1b094ffa24f4d60ce44fa79fa8efd37e81a75423 100644 --- a/Sources/ChatListFeature/ViewModel/ChatListViewModel.swift +++ b/Sources/ChatListFeature/ViewModel/ChatListViewModel.swift @@ -135,11 +135,15 @@ final class ChatListViewModel { isBanned: false ), groupChatInfoQuery: GroupChatInfo.Query( - authStatus: [.participating] + authStatus: [.participating], + isLeaderBlocked: false, + isLeaderBanned: false ), groupQuery: Group.Query( withMessages: false, - authStatus: [.participating] + authStatus: [.participating], + isLeaderBlocked: false, + isLeaderBanned: false ) )) .assertNoFailure() diff --git a/Sources/LaunchFeature/LaunchViewModel.swift b/Sources/LaunchFeature/LaunchViewModel.swift index 68f3fab87eff23ccdee9985c4bec27f3101f09df..5d85f07c60490f9ebcf11976d03ae68ef046199d 100644 --- a/Sources/LaunchFeature/LaunchViewModel.swift +++ b/Sources/LaunchFeature/LaunchViewModel.swift @@ -137,8 +137,10 @@ final class LaunchViewModel { } func getContactWith(userId: Data) -> Contact? { + let query = Contact.Query(id: [userId], isBlocked: false, isBanned: false) + guard let session = try? DependencyInjection.Container.shared.resolve() as SessionType, - let contact = try? session.dbManager.fetchContacts(.init(id: [userId])).first else { + let contact = try? session.dbManager.fetchContacts(query).first else { return nil } diff --git a/Sources/PushFeature/PushHandler.swift b/Sources/PushFeature/PushHandler.swift index f750c575899229ba5f6212261197087755dc8442..2e6dd801c618294f432cadbdea9a70d1d93493d6 100644 --- a/Sources/PushFeature/PushHandler.swift +++ b/Sources/PushFeature/PushHandler.swift @@ -115,6 +115,10 @@ public final class PushHandler: PushHandling { return ($0.type.unknownSenderContent!, $0) } + if contact.isBlocked || contact.isBanned { + return nil + } + let name = (contact.nickname ?? contact.username) ?? "" return ($0.type.knownSenderContent(name)!, $0) } diff --git a/Sources/SearchFeature/ViewModels/SearchRightViewModel.swift b/Sources/SearchFeature/ViewModels/SearchRightViewModel.swift index 5cfe38db68c498a15522f745174e41415281ba17..148db4ca424581596ccdea381a139ebfbb4cad11 100644 --- a/Sources/SearchFeature/ViewModels/SearchRightViewModel.swift +++ b/Sources/SearchFeature/ViewModels/SearchRightViewModel.swift @@ -78,6 +78,16 @@ final class SearchRightViewModel { /// that we already have /// if let alreadyContact = try? session.dbManager.fetchContacts(.init(id: [userId])).first { + if alreadyContact.isBlocked { + statusSubject.send(.failed(.unknown("You previously blocked this user."))) + return + } + + if alreadyContact.isBanned { + statusSubject.send(.failed(.unknown("This user was banned."))) + return + } + /// Show error accordingly to the auth status /// if alreadyContact.authStatus == .friend {