Compare commits

...

3 Commits

Author SHA1 Message Date
e2b3dc13fb chore(git): merge pull request #192 from cache-checks-9-9 into staging
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m16s
Reviewed-on: #192
Reviewed-by: s <s@noreply.git.nostrdev.com>
2024-09-10 08:48:53 +00:00
b
0244090c6a Merge branch 'staging' into cache-checks-9-9
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 35s
2024-09-09 18:44:36 +00:00
f0ba9da8af fix: outdated cache checks
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 33s
2024-09-09 14:16:58 +02:00

View File

@ -6,6 +6,7 @@ import { localCache } from '../services'
import { RelayMap, RelaySet } from '../types' import { RelayMap, RelaySet } from '../types'
import { import {
DEFAULT_LOOK_UP_RELAY_LIST, DEFAULT_LOOK_UP_RELAY_LIST,
ONE_DAY_IN_MS,
ONE_WEEK_IN_MS, ONE_WEEK_IN_MS,
SIGIT_RELAY SIGIT_RELAY
} from './const' } from './const'
@ -56,7 +57,7 @@ const findRelayListInCache = async (hexKey: string): Promise<Event | null> => {
// Check if the cached event is not older than one week // Check if the cached event is not older than one week
if ( if (
cachedRelayListMetadataEvent && cachedRelayListMetadataEvent &&
isOlderThanOneWeek(cachedRelayListMetadataEvent.cachedAt) !isOlderThanOneWeek(cachedRelayListMetadataEvent.cachedAt)
) { ) {
return cachedRelayListMetadataEvent.event return cachedRelayListMetadataEvent.event
} }
@ -88,11 +89,11 @@ const getDefaultRelayMap = (): RelayMap => ({
}) })
const isOlderThanOneWeek = (cachedAt: number) => { const isOlderThanOneWeek = (cachedAt: number) => {
return Date.now() - cachedAt < ONE_WEEK_IN_MS return Date.now() - cachedAt > ONE_WEEK_IN_MS
} }
const isOlderThanOneDay = (cachedAt: number) => { const isOlderThanOneDay = (cachedAt: number) => {
return Date.now() - cachedAt < ONE_WEEK_IN_MS return Date.now() - cachedAt > ONE_DAY_IN_MS
} }
const isRelayTag = (tag: string[]): boolean => tag[0] === 'r' const isRelayTag = (tag: string[]): boolean => tag[0] === 'r'