mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 15:27:24 +01:00
Removes NIP-04 DMs with hidden words from the Notification screen
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user