diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index 10e8955eb..fce48286a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -205,6 +205,7 @@ import com.vitorpamplona.quartz.nip98HttpAuth.HTTPAuthorizationEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceReplyEvent import com.vitorpamplona.quartz.utils.Log +import com.vitorpamplona.quartz.utils.containsAny import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers @@ -1677,6 +1678,16 @@ class Account( note.countReportAuthorsBy(followingKeySet()) < 5 // if it has 5 reports by reliable users } + fun isDecryptedContentHidden(noteEvent: PrivateDmEvent): Boolean = + if (hiddenUsers.flow.value.hiddenWordsCase + .isNotEmpty() + ) { + val decrypted = privateDMDecryptionCache.cachedDM(noteEvent) + decrypted?.containsAny(hiddenUsers.flow.value.hiddenWordsCase) == true + } else { + false + } + fun isFollowing(user: User): Boolean = user.pubkeyHex in followingKeySet() fun isFollowing(user: HexKey): Boolean = user in followingKeySet() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Note.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Note.kt index fd4d927f7..f5ea4fcf7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Note.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Note.kt @@ -42,6 +42,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.events.ETag import com.vitorpamplona.quartz.nip01Core.tags.events.EventReference import com.vitorpamplona.quartz.nip01Core.tags.hashtags.anyHashTag import com.vitorpamplona.quartz.nip01Core.tags.publishedAt.PublishedAtProvider +import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent import com.vitorpamplona.quartz.nip10Notes.BaseThreadedEvent import com.vitorpamplona.quartz.nip10Notes.tags.MarkedETag import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 330db6c99..f034169c8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -106,6 +106,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.SignerExceptions import com.vitorpamplona.quartz.nip01Core.tags.people.PubKeyReferenceTag import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser import com.vitorpamplona.quartz.nip03Timestamp.EmptyOtsResolverBuilder +import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent @@ -137,6 +138,7 @@ import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceEvent import com.vitorpamplona.quartz.utils.Hex import com.vitorpamplona.quartz.utils.Log import com.vitorpamplona.quartz.utils.TimeUtils +import com.vitorpamplona.quartz.utils.containsAny import com.vitorpamplona.quartz.utils.mapNotNullAsync import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.ImmutableSet @@ -348,7 +350,10 @@ class AccountViewModel( val isPostHidden = note.isHiddenFor(accountChoices) val isHiddenAuthor = note.author?.let { account.isHidden(it) } == true - return if (isPostHidden) { + val noteEvent = note.event + val isDecryptedPostHidden = if (noteEvent is PrivateDmEvent) account.isDecryptedContentHidden(noteEvent) else false + + return if (isPostHidden || isDecryptedPostHidden) { // Spam + Blocked Users + Hidden Words + Sensitive Content NoteComposeReportState(isPostHidden, false, false, isHiddenAuthor) } else if (isFromLoggedIn || isFromLoggedInFollow) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt index ed5a07640..4a4c37a5d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt @@ -34,8 +34,10 @@ import com.vitorpamplona.quartz.experimental.forks.isForkFromAddressWithPubkey import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser +import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent import com.vitorpamplona.quartz.nip10Notes.BaseThreadedEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent +import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent @@ -67,6 +69,7 @@ import com.vitorpamplona.quartz.nip90Dvms.NIP90ContentDiscoveryRequestEvent import com.vitorpamplona.quartz.nip90Dvms.NIP90ContentDiscoveryResponseEvent import com.vitorpamplona.quartz.nip90Dvms.NIP90StatusEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent +import com.vitorpamplona.quartz.utils.containsAny class NotificationFeedFilter( val account: Account, @@ -148,22 +151,23 @@ class NotificationFeedFilter( } } - return it.event !is ChannelCreateEvent && - it.event !is ChannelMetadataEvent && - it.event !is LnZapRequestEvent && - it.event !is BadgeDefinitionEvent && - it.event !is BadgeProfilesEvent && - it.event !is NIP90ContentDiscoveryResponseEvent && - it.event !is NIP90StatusEvent && - it.event !is NIP90ContentDiscoveryRequestEvent && - it.event !is GiftWrapEvent && - it.event !is PrivateTagArrayEvent && - it.event !is LnZapPaymentRequestEvent && - it.event !is LnZapPaymentResponseEvent && - (it.event is LnZapEvent || notifAuthor != loggedInUserHex) && + return noteEvent !is ChannelCreateEvent && + noteEvent !is ChannelMetadataEvent && + noteEvent !is LnZapRequestEvent && + noteEvent !is BadgeDefinitionEvent && + noteEvent !is BadgeProfilesEvent && + noteEvent !is NIP90ContentDiscoveryResponseEvent && + noteEvent !is NIP90StatusEvent && + noteEvent !is NIP90ContentDiscoveryRequestEvent && + noteEvent !is GiftWrapEvent && + noteEvent !is PrivateTagArrayEvent && + noteEvent !is LnZapPaymentRequestEvent && + noteEvent !is LnZapPaymentResponseEvent && + (noteEvent is LnZapEvent || notifAuthor != loggedInUserHex) && (filterParams.isGlobal(it.relays) || notifAuthor == null || filterParams.isAuthorInFollows(notifAuthor)) && - it.event?.isTaggedUser(loggedInUserHex) ?: false && + noteEvent?.isTaggedUser(loggedInUserHex) ?: false && (filterParams.isHiddenList || notifAuthor == null || !account.isHidden(notifAuthor)) && + (noteEvent !is PrivateDmEvent || !account.isDecryptedContentHidden(noteEvent)) && tagsAnEventByUser(it, loggedInUserHex) }