Adds a lastReportedTime field (to be used with Since in the websocket filter) for Users with too many reports.

This commit is contained in:
Vitor Pamplona
2023-02-18 19:14:27 -05:00
parent de2ec503da
commit 0914a7b68c
@@ -13,8 +13,10 @@ import java.util.concurrent.atomic.AtomicBoolean
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import nostr.postr.events.ContactListEvent import nostr.postr.events.ContactListEvent
import nostr.postr.events.MetadataEvent import nostr.postr.events.MetadataEvent
import nostr.postr.toNpub import nostr.postr.toNpub
@@ -43,6 +45,7 @@ class User(val pubkeyHex: String) {
var reports = mapOf<User, Set<Note>>() var reports = mapOf<User, Set<Note>>()
private set private set
var latestReportTime: Long = 0
var zaps = mapOf<Note, Note?>() var zaps = mapOf<Note, Note?>()
private set private set
@@ -140,6 +143,11 @@ class User(val pubkeyHex: String) {
reports = reports + Pair(author, (reports[author] ?: emptySet()) + note) reports = reports + Pair(author, (reports[author] ?: emptySet()) + note)
liveReports.invalidateData() liveReports.invalidateData()
} }
val reportTime = note.event?.createdAt ?: 0
if (reportTime > latestReportTime) {
latestReportTime = reportTime
}
} }
fun addZap(zapRequest: Note, zap: Note?) { fun addZap(zapRequest: Note, zap: Note?) {