-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/blinded version #1583
Feature/blinded version #1583
Conversation
Co-authored-by: fanchao <[email protected]>
Fixed randomly found timeunit error
private var job: Job? = null | ||
|
||
init { | ||
runnable = Runnable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline
app/src/main/java/org/thoughtcrime/securesms/util/VersionUtil.kt
Outdated
Show resolved
Hide resolved
|
||
object BlindKeyAPI { | ||
init { | ||
System.loadLibrary("session_util") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would perhaps be ideal to just have one by lazy
somewhere that we reference instead of loading this thing for the 8th time.
IDK if it's optimised away sometimes/always/never, but at least when we loaded a lib way to many times, it crashed on some devices.
libsession/src/main/java/org/session/libsession/snode/utilities/PromiseUtil.kt
Outdated
Show resolved
Hide resolved
?: throw (Error.NoEd25519KeyPair) | ||
|
||
val blindedKeys = BlindKeyAPI.blindVersionKeyPair(secretKey) | ||
val timestamp = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) // The current timestamp in seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so... you could perhaps more clearly:
val timestampSeconds = System.currentTimeMillis().milliseconds.inWholeSeconds
as it's useful to put units in the variable name if it is not contained in the type.
alternatively
val timestamp = System.currentTimeMillis().milliseconds
val signature = BlindKeyAPI.blindVersionSign(secretKey, timestamp.inWholeSeconds)
...
"X-FS-Timestamp" to timestamp.inWholeSeconds.toString(),
Co-authored-by: Andrew <[email protected]>
val json = JsonUtil.fromJson(result, Map::class.java) | ||
val statusCode = json.getOrDefault("status_code", 0) as Int | ||
val version = json.getOrDefault("result", "") as String | ||
val updated = json.getOrDefault("updated", 0.0) as Double | ||
|
||
return VersionData(statusCode, version, updated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing as there's all of these named vals that are simple enough to inline, they may as well be named params, and you get a little bit more safety that they're in the right order etc.
val json = JsonUtil.fromJson(result, Map::class.java) | |
val statusCode = json.getOrDefault("status_code", 0) as Int | |
val version = json.getOrDefault("result", "") as String | |
val updated = json.getOrDefault("updated", 0.0) as Double | |
return VersionData(statusCode, version, updated) | |
return JsonUtil.fromJson(result, Map::class.java).let { | |
VersionData( | |
statusCode = it["status_code"] as? Int ?: 0 | |
version = it["result"] as? String ?: "" | |
updated = it["updated"] as? Double ?: 0.0 | |
) | |
} |
@@ -142,6 +143,7 @@ public class ApplicationContext extends Application implements DefaultLifecycleO | |||
private HandlerThread conversationListHandlerThread; | |||
private Handler conversationListHandler; | |||
private PersistentLogger persistentLogger; | |||
private VersionUtil versionUtil; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could probably inject without much trouble
…s/PromiseUtil.kt Co-authored-by: Andrew <[email protected]>
SES-2483 - Updated Version API
We need the app to periodically (every 4hours at most) check the latest app version,
which is available on the File server API.
Two new endpoints were added to libsession to help with the required headers for the new version endpoint.
JNI bridging added in.