session-android/libsession/src/main/java/org/session/libsession/snode/SnodeMessage.kt

36 lines
898 B
Kotlin
Raw Normal View History

package org.session.libsession.snode
2021-05-18 01:34:45 +02:00
import org.session.libsignal.utilities.removing05PrefixIfNeeded
data class SnodeMessage(
2021-05-13 02:33:34 +02:00
/**
* The hex encoded public key of the recipient.
*/
val recipient: String,
2021-05-13 02:33:34 +02:00
/**
* The content of the message.
*/
val data: String,
2021-05-13 02:33:34 +02:00
/**
* The time to live for the message in milliseconds.
*/
val ttl: Long,
2021-05-13 02:33:34 +02:00
/**
* When the proof of work was calculated.
*
* **Note:** Expressed as milliseconds since 00:00:00 UTC on 1 January 1970.
*/
val timestamp: Long
) {
2021-04-26 02:26:31 +02:00
internal fun toJSON(): Map<String, String> {
2021-04-26 02:26:31 +02:00
return mapOf(
"pubKey" to if (SnodeAPI.useTestnet) recipient.removing05PrefixIfNeeded() else recipient,
2021-05-13 02:33:34 +02:00
"data" to data,
"ttl" to ttl.toString(),
"timestamp" to timestamp.toString(),
"nonce" to ""
2021-04-26 02:26:31 +02:00
)
}
}