-
Notifications
You must be signed in to change notification settings - Fork 731
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
Live Location Sharing - Beacon Info #5651
Conversation
Unit Test Results110 files + 4 110 suites +4 1m 21s ⏱️ +15s Results for commit 273b481. ± Comparison against base commit 3cf7765. This pull request removes 2 and adds 9 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
*/ | ||
@Json(name = "m.beacon_info") val beaconInfo: BeaconInfo? = null, | ||
/** | ||
* Beacon creation timestamp. |
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.
I'm not sure if we do it in other places, but it might be handy to know the timestamp format, for example epoch seconds or milliseconds
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.
Renamed and used clock class.
@@ -40,6 +47,7 @@ class LocationSharingService : VectorService(), LocationTracker.Callback { | |||
|
|||
@Inject lateinit var notificationUtils: NotificationUtils | |||
@Inject lateinit var locationTracker: LocationTracker | |||
@Inject lateinit var session: Session |
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.
is it safe to inject the session
directly or should we use the ActiveSessionHolder
? 🤔
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.
Right, not safe here. Done.
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.
thanks for the updates! might be worth a second pair of eyes from @mnaturel
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.
Some remarks
@@ -49,6 +49,7 @@ object EventType { | |||
const val STATE_ROOM_JOIN_RULES = "m.room.join_rules" | |||
const val STATE_ROOM_GUEST_ACCESS = "m.room.guest_access" | |||
const val STATE_ROOM_POWER_LEVELS = "m.room.power_levels" | |||
const val STATE_ROOM_BEACON_INFO = "m.beacon_info" |
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.
There is no unstable prefix?
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.
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.
Oh no, of course there is. Thanks for catching.
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.
Fixed.
session.coroutineScope.launch { | ||
sendBeaconInfo(session, roomArgs) | ||
} | ||
} |
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.
Just to double check: this code does not send multiple beacon events during a period of time, but just one event, right?
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.
Yes, location events will be sent later.
session | ||
.getRoom(roomArgs.roomId) | ||
?.sendStateEvent( | ||
eventType = EventType.STATE_ROOM_BEACON_INFO, |
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.
see the MCS: type should have the form "m.beacon_info.@stefan:matrix.org"
https://github.com/matrix-org/matrix-spec-proposals/blob/stefan/ephemeral-location-streaming/proposals/3672-ephemeral-location-streaming.md#proposal
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.
dynamic keys are quite painful for json parsers, do we have other examples of them in the spec? would be great to avoid and replace with a content value if possible
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.
We also have https://github.com/matrix-org/matrix-spec-proposals/blob/andybalaam/owner-state-events/proposals/3757-restricting-who-can-overwrite-a-state-event.md but let me clarify this with the team.
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.
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.
I need to test to confirm. But seems good to me. I just have small remarks.
Is it also possible to update the PR description with the correct links to the MSCs we eventually use?
@@ -0,0 +1,33 @@ | |||
/* | |||
* Copyright 2020 The Matrix.org Foundation C.I.C. |
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.
Can you update the date to 2022?
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.
Nice catch :) Done.
@@ -0,0 +1,47 @@ | |||
/* | |||
* Copyright 2020 The Matrix.org Foundation C.I.C. |
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.
Same comment about the date.
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.
Done.
* limitations under the License. | ||
*/ | ||
|
||
package org.matrix.android.sdk.api.session.room.model |
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.
Maybe we should create a dedicated subpackage for models concerning the live location feature? For instance livelocation
. Or do you think it is in the right package?
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.
I was thinking about this, done.
* Beacon creation timestamp. | ||
*/ | ||
@Json(name = "org.matrix.msc3488.ts") val unstableTimestampAsMilliseconds: Long? = null, | ||
@Json(name = "m.ts") val timestampAsMillisecond: Long? = null, |
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.
Is it possible to unify the naming? Indeed, the unstable field has an ending "s" in its name and the stable one has no ending "s".
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.
Nice catch, done.
/** | ||
* Live location asset type. | ||
*/ | ||
@Json(name = "org.matrix.msc3488.asset") val unstableLocationAsset: LocationAsset = LocationAsset("m.self"), |
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.
Is it possible to use the defined const value LocationAssetType.SELF
instead of "m.self"?
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.
Right, it has been changed. Done.
activeSessionHolder | ||
.getSafeActiveSession() | ||
?.let { session -> | ||
session.coroutineScope.launch { |
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.
Maybe it would be better to precise the IO Dispatcher here like this:
session.coroutineScope.launch(session.coroutineDispatchers.io) {
sendBeaconInfo(session, roomArgs)
}
I am not sure but reading the implementation of SessionCoroutineScopes, it seems the default Dispatcher is the Main one. @ouchadam or @bmarty could you confirm? Or am I missing something?
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.
I am also not so confident, but IO seems better. @bmarty?
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.
Session.getRoom()
is a blocking non suspend call, ideally the api would be suspending and internally use the correct dispatcher where needed, until then wrapping with an IO context would be better!
I thought this would have triggered a network on main thread warning 🤔
MSC 3672
A beacon info state event needs to be sent when live location sharing started.