chore: drop MAX_WAKEUP_REFS cap in wakeUpFor
Filter assemblers already handle batching and sizing; capping here adds nothing.
This commit is contained in:
+2
-13
@@ -90,10 +90,6 @@ class EventNotificationConsumer(
|
|||||||
companion object {
|
companion object {
|
||||||
private const val WAKELOCK_TIMEOUT_MS = 10 * 60 * 1000L // 10 minutes
|
private const val WAKELOCK_TIMEOUT_MS = 10 * 60 * 1000L // 10 minutes
|
||||||
private const val WAKEUP_WINDOW_MS = 30_000L
|
private const val WAKEUP_WINDOW_MS = 30_000L
|
||||||
|
|
||||||
// Upper bound on referenced events we'll chase per WakeUp. Guards against
|
|
||||||
// a malicious sender opening hundreds of subscriptions per wake-up.
|
|
||||||
private const val MAX_WAKEUP_REFS = 16
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,11 +190,7 @@ class EventNotificationConsumer(
|
|||||||
) {
|
) {
|
||||||
// A WakeUp's whole purpose is the events it references. If it carries
|
// A WakeUp's whole purpose is the events it references. If it carries
|
||||||
// none, there's nothing to fetch — skip the 30s subscription window.
|
// none, there's nothing to fetch — skip the 30s subscription window.
|
||||||
val referencedTags =
|
val referencedTags = event.events().distinctBy { it.eventId }
|
||||||
event
|
|
||||||
.events()
|
|
||||||
.distinctBy { it.eventId }
|
|
||||||
.take(MAX_WAKEUP_REFS)
|
|
||||||
if (referencedTags.isEmpty()) {
|
if (referencedTags.isEmpty()) {
|
||||||
Log.d(TAG) { "WakeUp ${event.id} has no referenced events — skipping" }
|
Log.d(TAG) { "WakeUp ${event.id} has no referenced events — skipping" }
|
||||||
return
|
return
|
||||||
@@ -208,13 +200,10 @@ class EventNotificationConsumer(
|
|||||||
// events; those are whose metadata we need to render the notification.
|
// events; those are whose metadata we need to render the notification.
|
||||||
// Fall back to e-tag author hints and finally to the WakeUp signer.
|
// Fall back to e-tag author hints and finally to the WakeUp signer.
|
||||||
val referencedNotes = referencedTags.map { LocalCache.getOrCreateNote(it.eventId) }
|
val referencedNotes = referencedTags.map { LocalCache.getOrCreateNote(it.eventId) }
|
||||||
val authorKeys =
|
val authorCandidates =
|
||||||
(event.authorKeys() + referencedTags.mapNotNull { it.author })
|
(event.authorKeys() + referencedTags.mapNotNull { it.author })
|
||||||
.distinct()
|
.distinct()
|
||||||
.ifEmpty { listOf(event.pubKey) }
|
.ifEmpty { listOf(event.pubKey) }
|
||||||
val authorCandidates =
|
|
||||||
authorKeys
|
|
||||||
.take(MAX_WAKEUP_REFS)
|
|
||||||
.map { LocalCache.getOrCreateUser(it) }
|
.map { LocalCache.getOrCreateUser(it) }
|
||||||
|
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
|
|||||||
Reference in New Issue
Block a user