1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-22 08:46:15 +00:00

JSON objects now also contain a property api_layer containing their (surprise!) api_layer.

This commit is contained in:
Fabian Schlenz 2018-04-19 17:48:11 +02:00
parent bb2a291d4f
commit 11a6318a26

View File

@ -18,6 +18,9 @@ package de.fabianonline.telegram_backup
import com.github.badoualy.telegram.tl.exception.RpcErrorException
import com.github.badoualy.telegram.tl.api.TLAbsMessage
import com.github.badoualy.telegram.tl.api.TLAbsUser
import com.github.badoualy.telegram.tl.api.TLAbsChat
import com.github.badoualy.telegram.api.Kotlogram
import java.io.File
import java.util.Vector
import java.util.concurrent.TimeUnit
@ -230,8 +233,21 @@ fun JsonElement.isA(name: String): Boolean = this.obj.isA(name)
class MaxTriesExceededException(): RuntimeException("Max tries exceeded") {}
fun TLAbsMessage.toJson(): String {
val json = Gson().toJsonTree(this)
val json = Gson().toJsonTree(this).obj
cleanUpMessageJson(json)
json["api_layer"] = Kotlogram.API_LAYER
return json.toString()
}
fun TLAbsChat.toJson(): String {
val json = Gson().toJsonTree(this).obj
json["api_layer"] = Kotlogram.API_LAYER
return json.toString()
}
fun TLAbsUser.toJson(): String {
val json = Gson().toJsonTree(this).obj
json["api_layer"] = Kotlogram.API_LAYER
return json.toString()
}