Use epoch Seconds instead of epochMilliseconds

This commit is contained in:
Kgothatso Ngako
2026-03-30 13:04:36 +02:00
parent 31b1980e2b
commit 9fade17836
6 changed files with 24 additions and 24 deletions

View File

@@ -13,12 +13,12 @@ class AuxConverters {
@TypeConverter
fun fromTimestamp(value: Long?): Instant? {
return value?.let { Instant.fromEpochMilliseconds(it) }
return value?.let { Instant.fromEpochSeconds(it) }
}
@TypeConverter
fun instantToTimestamp(instant: Instant?): Long? {
return instant?.toEpochMilliseconds()
return instant?.epochSeconds
}
@TypeConverter

View File

@@ -86,7 +86,7 @@ data class NostrEvent(
val textNote = EventFactory.create<TextNoteEvent>(
id = id,
pubKey = pubKey,
createdAt = createdAt.toEpochMilliseconds(),
createdAt = createdAt.epochSeconds,
kind = kind,
tags = tags,
content = content,
@@ -101,8 +101,8 @@ data class NostrEvent(
nostrEventId = id,
replyToId = textNote.replyingTo(),
profilePublicKey = textNote.pubKey,
createdAt = Instant.fromEpochMilliseconds(textNote.createdAt),
updatedAt = Instant.fromEpochMilliseconds(textNote.createdAt),
createdAt = Instant.fromEpochSeconds(textNote.createdAt),
updatedAt = Instant.fromEpochSeconds(textNote.createdAt),
)
}
return null
@@ -116,7 +116,7 @@ data class NostrEvent(
val metadataEvent = EventFactory.create<MetadataEvent>(
id = id,
pubKey = pubKey,
createdAt = createdAt.toEpochMilliseconds(),
createdAt = createdAt.epochSeconds,
kind = kind,
tags = tags,
content = content,
@@ -128,8 +128,8 @@ data class NostrEvent(
publicKey = pubKey,
nostrEventId = id,
createdAt = Instant.fromEpochMilliseconds(metadataEvent.createdAt),
updatedAt = Instant.fromEpochMilliseconds(metadataEvent.createdAt),
createdAt = Instant.fromEpochSeconds(metadataEvent.createdAt),
updatedAt = Instant.fromEpochSeconds(metadataEvent.createdAt),
userName = userMetadata.name,
displayName = userMetadata.displayName,
@@ -158,7 +158,7 @@ data class NostrEvent(
val reactionEvent = EventFactory.create<ReactionEvent>(
id = id,
pubKey = pubKey,
createdAt = createdAt.toEpochMilliseconds(),
createdAt = createdAt.epochSeconds,
kind = kind,
tags = tags,
content = content,
@@ -174,8 +174,8 @@ data class NostrEvent(
replyToId = reactedTo,
profilePublicKey = reactionEvent.pubKey,
createdAt = Instant.fromEpochMilliseconds(reactionEvent.createdAt),
updatedAt = Instant.fromEpochMilliseconds(reactionEvent.createdAt),
createdAt = Instant.fromEpochSeconds(reactionEvent.createdAt),
updatedAt = Instant.fromEpochSeconds(reactionEvent.createdAt),
)
}
}
@@ -190,7 +190,7 @@ data class NostrEvent(
val repostEvent = EventFactory.create<RepostEvent>(
id = id,
pubKey = pubKey,
createdAt = createdAt.toEpochMilliseconds(),
createdAt = createdAt.epochSeconds,
kind = kind,
tags = tags,
content = content,
@@ -206,8 +206,8 @@ data class NostrEvent(
nostrEventId = id,
profilePublicKey = repostEvent.pubKey,
createdAt = Instant.fromEpochMilliseconds(repostEvent.createdAt),
updatedAt = Instant.fromEpochMilliseconds(repostEvent.createdAt),
createdAt = Instant.fromEpochSeconds(repostEvent.createdAt),
updatedAt = Instant.fromEpochSeconds(repostEvent.createdAt),
)
}
}
@@ -223,7 +223,7 @@ data class NostrEvent(
val zapEvent = EventFactory.create<LnZapEvent>(
id = id,
pubKey = pubKey,
createdAt = createdAt.toEpochMilliseconds(),
createdAt = createdAt.epochSeconds,
kind = kind,
tags = tags,
content = content,

View File

@@ -68,7 +68,7 @@ class DatabaseNostrRepository(
UnsignedNostrEvent(
pubKey = publicKey,
kind = profileEventTemplate.kind,
createdAt = Instant.fromEpochMilliseconds(profileEventTemplate.createdAt),
createdAt = Instant.fromEpochSeconds(profileEventTemplate.createdAt),
tags = profileEventTemplate.tags,
content = profileEventTemplate.content,
signedAt = signedAt // This will keep us from trying to sign this event... but we should automatically sync the npub profile
@@ -111,7 +111,7 @@ class DatabaseNostrRepository(
UnsignedNostrEvent(
pubKey = publicKey,
kind = textNote.kind,
createdAt = Instant.fromEpochMilliseconds(textNote.createdAt),
createdAt = Instant.fromEpochSeconds(textNote.createdAt),
tags = textNote.tags,
content = textNote.content
)

View File

@@ -53,7 +53,7 @@ class NostrEventBroadcaster(
content = nostrEvent.content,
tags = nostrEvent.tags,
sig = nostrEvent.sig,
createdAt = nostrEvent.createdAt.toEpochMilliseconds()
createdAt = nostrEvent.createdAt.epochSeconds
)
}

View File

@@ -51,7 +51,7 @@ fun UnsignedProfileScreen(
val metadataEvent = MetadataEvent(
id = unsignedNostrEvent.id.toString(),
pubKey = unsignedNostrEvent.pubKey,
createdAt = unsignedNostrEvent.createdAt.toEpochMilliseconds(),
createdAt = unsignedNostrEvent.createdAt.epochSeconds,
tags = unsignedNostrEvent.tags,
content = unsignedNostrEvent.content,
sig = ""

View File

@@ -108,7 +108,7 @@ class NavigationViewModel(
unsignedNostrEventOrNull?.let { unsignedNostrEvent ->
logger.d("Unsigned")
val event = tempSigner.signNormal<Event>(
createdAt = unsignedNostrEvent.createdAt.toEpochMilliseconds(),
createdAt = unsignedNostrEvent.createdAt.epochSeconds,
kind = unsignedNostrEvent.kind,
tags = unsignedNostrEvent.tags,
content = unsignedNostrEvent.content
@@ -122,7 +122,7 @@ class NavigationViewModel(
kind = event.kind,
tags = event.tags,
content = event.content,
createdAt = Instant.fromEpochMilliseconds(event.createdAt),
createdAt = Instant.fromEpochSeconds(event.createdAt),
sig = event.sig,
unsignedNostrEventId = unsignedNostrEvent.id
),
@@ -151,8 +151,8 @@ class NavigationViewModel(
ids = synchronizeNostrEventRequest.eventIds?.map { eventId -> eventId },
authors = synchronizeNostrEventRequest.authorPublicKeys?.map { authorPublicKey -> authorPublicKey },
kinds = synchronizeNostrEventRequest.kinds?.map { kind -> kind },
since = synchronizeNostrEventRequest.since?.toEpochMilliseconds(),
until = synchronizeNostrEventRequest.until?.toEpochMilliseconds(),
since = synchronizeNostrEventRequest.since?.epochSeconds,
until = synchronizeNostrEventRequest.until?.epochSeconds,
limit = synchronizeNostrEventRequest.limit,
search = synchronizeNostrEventRequest.search
)
@@ -200,7 +200,7 @@ class NavigationViewModel(
kind = event.kind,
content = event.content,
tags = event.tags,
createdAt = Instant.fromEpochMilliseconds(event.createdAt),
createdAt = Instant.fromEpochSeconds(event.createdAt),
unsignedNostrEventId = synchronizeNostrEventRequest.unsignedNostrEventId,
sig = event.sig
)