Skip to content
Snippets Groups Projects
Commit 8bc4ea6d authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Rejecting notifications from banned/blocked users and not allowing to scan those

parent 77bdf63c
No related branches found
No related tags found
3 merge requests!71Releasing v1.1.5 (214),!69Implemented filtering for banned/blocked users and reporting,!67v1.1.5 b(203)
...@@ -103,7 +103,13 @@ final class GroupChatViewModel { ...@@ -103,7 +103,13 @@ final class GroupChatViewModel {
return "[DELETED]" 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) { func didRequestReply(_ message: Message) {
......
...@@ -135,11 +135,15 @@ final class ChatListViewModel { ...@@ -135,11 +135,15 @@ final class ChatListViewModel {
isBanned: false isBanned: false
), ),
groupChatInfoQuery: GroupChatInfo.Query( groupChatInfoQuery: GroupChatInfo.Query(
authStatus: [.participating] authStatus: [.participating],
isLeaderBlocked: false,
isLeaderBanned: false
), ),
groupQuery: Group.Query( groupQuery: Group.Query(
withMessages: false, withMessages: false,
authStatus: [.participating] authStatus: [.participating],
isLeaderBlocked: false,
isLeaderBanned: false
) )
)) ))
.assertNoFailure() .assertNoFailure()
......
...@@ -137,8 +137,10 @@ final class LaunchViewModel { ...@@ -137,8 +137,10 @@ final class LaunchViewModel {
} }
func getContactWith(userId: Data) -> Contact? { 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, 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 return nil
} }
......
...@@ -115,6 +115,10 @@ public final class PushHandler: PushHandling { ...@@ -115,6 +115,10 @@ public final class PushHandler: PushHandling {
return ($0.type.unknownSenderContent!, $0) return ($0.type.unknownSenderContent!, $0)
} }
if contact.isBlocked || contact.isBanned {
return nil
}
let name = (contact.nickname ?? contact.username) ?? "" let name = (contact.nickname ?? contact.username) ?? ""
return ($0.type.knownSenderContent(name)!, $0) return ($0.type.knownSenderContent(name)!, $0)
} }
......
...@@ -78,6 +78,16 @@ final class SearchRightViewModel { ...@@ -78,6 +78,16 @@ final class SearchRightViewModel {
/// that we already have /// that we already have
/// ///
if let alreadyContact = try? session.dbManager.fetchContacts(.init(id: [userId])).first { 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 /// Show error accordingly to the auth status
/// ///
if alreadyContact.authStatus == .friend { if alreadyContact.authStatus == .friend {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment