Skip to content
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 - Send location data #5697

Merged
merged 5 commits into from
Apr 6, 2022

Conversation

onurays
Copy link
Contributor

@onurays onurays commented Apr 5, 2022

Sends beacon pulse events with a reference to the initial beacon info event.

{
  "type": "org.matrix.msc3672.beacon",
  "sender": "@user:matrix.org",
  "room_id": "!abc123:matrix.org",
  "content": {
    "m.relates_to": {
      "event_id": "<m.beacon_info event_id>",
      "rel_type": "m.reference"
    },
    "org.matrix.msc3488.location": {
      "uri": "geo:53.99803101552848,-8.25347900390625;u=10"
    },
    "org.matrix.msc3488.ts": 1648820683092
  }
}

@onurays onurays requested review from a team and ericdecanini and removed request for a team April 5, 2022 09:56
@github-actions
Copy link

github-actions bot commented Apr 5, 2022

Unit Test Results

110 files  ±0  110 suites  ±0   1m 35s ⏱️ +12s
195 tests ±0  195 ✔️ ±0  0 💤 ±0  0 ±0 
650 runs  ±0  650 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit e0d59ef. ± Comparison against base commit e2481fa.

♻️ This comment has been updated with latest results.

val room = activeSessionHolder.getSafeActiveSession()?.getRoom(roomArg.roomId)
room?.getStateEvent(EventType.STATE_ROOM_BEACON_INFO.first())?.let { beaconInfoEvent ->
room.sendLiveLocation(
beaconInfoEventId = beaconInfoEvent.eventId!!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Would it make sense to chain this before the let to avoid the force unwrap? Looks like you're not reading anything else from the event here anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, done. (Although I don't know why event id is nullable).

@onurays onurays requested review from a team and ouchadam and removed request for ericdecanini and a team April 5, 2022 12:50
@@ -49,7 +49,8 @@ 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"
private const val STATE_ROOM_BEACON_INFO_PREFIX = "org.matrix.msc3489.beacon_info."
val STATE_ROOM_BEACON_INFO = listOf("org.matrix.msc3672.beacon_info", "m.beacon_info")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of interest, how come we've turned these into a list? looks like we're always using the first item~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spec introduced unstable prefixes recently. We use them until MSCs are merged. Then we will send stable ones, so we also need to support previously sent unstable ones.

I am thinking about a better approach. We have similar events for polls and there will be more coming.

Copy link
Contributor

@ouchadam ouchadam Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explanation! could be nice to have way to say STATE_ROOM_BEACON_INFO.stable/unstable() instead of STATE_ROOM_BEACON_INFO.first()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea, I will improve all in another PR


// Emit location update to all rooms in which live location sharing is active
roomArgsList.forEach { roomArg ->
sendLiveLocation(roomArg.roomId, locationData)
Copy link
Contributor

@ouchadam ouchadam Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is sendLiveLocation a blocking network call? it might need a io dispatchers~ anddd it might be safer to copy the roomArgsList to avoid also blocking the synchronised calls

val inputs = roomArgsList.toList()

job?.cancel()
job = scope.launch(io) {
  inputs.forEach { sendLiveLocation() }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use CoroutineScope in EventSenderProcessorCoroutine.launchWith(). Securing list is a good idea and done.

@onurays onurays merged commit 2a42eb8 into develop Apr 6, 2022
@onurays onurays deleted the feature/ons/live_location_pulse branch April 6, 2022 12:35

@Json(name = "body") override val body: String = "",
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
@Json(name = "m.new_content") override val newContent: Content? = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stupid question, sorry: This doesn't seem to be read or set anywhere in this diff. I also haven't seen this on any of the location sharing MSCs. What is this field used for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants