Fix last_checked again

This commit is contained in:
Jonathan Staab 2023-05-04 17:41:30 -07:00
parent d4f26abad4
commit ce19810762
2 changed files with 17 additions and 6 deletions

View File

@ -1,5 +1,8 @@
# Current
- [ ] Add search for topics
- [ ] Fix relay recommendations
- [ ] Pagination is slow. Maybe load with no window first, then add since?
- [ ] Add coupon code registration for relay
- [ ] Repurpose chat as groups
- [ ] Avoid leaking events from private relays

View File

@ -1,4 +1,4 @@
import {filter, is, uniq, prop, reject, nth, uniqBy, objOf, pick, identity} from "ramda"
import {is, uniq, prop, reject, nth, uniqBy, objOf, pick, identity} from "ramda"
import {nip05} from "nostr-tools"
import {noop, ensurePlural, chunk} from "hurdak/lib/hurdak"
import {
@ -251,12 +251,20 @@ addHandler(
30078,
profileHandler("last_checked", async (e, p) => {
if (Tags.from(e).getMeta("d") === "coracle/last_checked/v1") {
const updates = filter(
([k, v]) => p.last_checked[k] || 0 < v,
Object.entries(await keys.decryptJson(e.content))
)
const payload = await keys.decryptJson(e.content)
const updates = {}
for (const k of Object.keys(payload).concat(p.last_checked)) {
const v = Math.max(payload[k] || 0, p.last_checked[k] || 0)
return {...p.last_checked, ...updates}
// A bunch of junk got added to this setting. Integer keys, settings, etc
if (isNaN(v) || v < 1577836800) {
continue
}
updates[k] = v
}
return updates
}
})
)