Do not use System.currentTimeMillis()
This commit is contained in:
parent
cede53579c
commit
42bafbdc1a
1 changed files with 23 additions and 21 deletions
|
|
@ -29,6 +29,7 @@ import io.element.android.libraries.push.impl.log.pushLoggerTag
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
||||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||||
|
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
@ -46,6 +47,7 @@ class NotifiableEventResolver @Inject constructor(
|
||||||
// private val displayableEventFormatter: DisplayableEventFormatter,
|
// private val displayableEventFormatter: DisplayableEventFormatter,
|
||||||
private val matrixAuthenticationService: MatrixAuthenticationService,
|
private val matrixAuthenticationService: MatrixAuthenticationService,
|
||||||
private val buildMeta: BuildMeta,
|
private val buildMeta: BuildMeta,
|
||||||
|
private val clock: SystemClock,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun resolveEvent(sessionId: SessionId, roomId: RoomId, eventId: EventId): NotifiableEvent? {
|
suspend fun resolveEvent(sessionId: SessionId, roomId: RoomId, eventId: EventId): NotifiableEvent? {
|
||||||
|
|
@ -96,27 +98,27 @@ class NotifiableEventResolver @Inject constructor(
|
||||||
isUpdated = false
|
isUpdated = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO This is a temporary method for EAx.
|
* TODO This is a temporary method for EAx.
|
||||||
*/
|
*/
|
||||||
private fun NotificationData?.orDefault(roomId: RoomId, eventId: EventId): NotificationData {
|
private fun NotificationData?.orDefault(roomId: RoomId, eventId: EventId): NotificationData {
|
||||||
return this ?: NotificationData(
|
return this ?: NotificationData(
|
||||||
eventId = eventId,
|
eventId = eventId,
|
||||||
senderId = UserId("@user:domain"),
|
senderId = UserId("@user:domain"),
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
senderAvatarUrl = null,
|
senderAvatarUrl = null,
|
||||||
senderDisplayName = null,
|
senderDisplayName = null,
|
||||||
roomAvatarUrl = null,
|
roomAvatarUrl = null,
|
||||||
roomDisplayName = null,
|
roomDisplayName = null,
|
||||||
isNoisy = false,
|
isNoisy = false,
|
||||||
isEncrypted = false,
|
isEncrypted = false,
|
||||||
isDirect = false,
|
isDirect = false,
|
||||||
event = NotificationEvent(
|
event = NotificationEvent(
|
||||||
timestamp = System.currentTimeMillis(),
|
timestamp = clock.epochMillis(),
|
||||||
content = "Message ${eventId.value.take(8)}… in room ${roomId.value.take(8)}…",
|
content = "Message ${eventId.value.take(8)}… in room ${roomId.value.take(8)}…",
|
||||||
contentUrl = null
|
contentUrl = null
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue