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

Unstable support for MSC 3489 live location sharing #1722

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

torrybr
Copy link

@torrybr torrybr commented Jan 26, 2024

This merge request introduces the live location sharing feature as per MSC3489.

These changes allow users to share their live location, start and stop the sharing, and check if the location sharing is live.

@torrybr torrybr changed the title Unstable support for MSC 348 live location sharing Unstable support for MSC 3489 live location sharing Jan 26, 2024
Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Hi, and thanks for the PR!

Please note that all of the modules in ruma-events that define event (content) types are named after the event type. That means that the live_location module you added should be split into two modules beacon and beacon_info.

crates/ruma-events/src/live_location.rs Outdated Show resolved Hide resolved
crates/ruma-events/src/beacon.rs Outdated Show resolved Hide resolved
crates/ruma-events/src/beacon.rs Outdated Show resolved Hide resolved
@torrybr torrybr force-pushed the feat/live-location branch 3 times, most recently from c32b059 to e644e8a Compare April 3, 2024 19:00
@torrybr torrybr marked this pull request as draft April 21, 2024 01:01
@torrybr torrybr force-pushed the feat/live-location branch 2 times, most recently from a996c48 to 14b3ab1 Compare April 21, 2024 16:09
@torrybr torrybr force-pushed the feat/live-location branch 3 times, most recently from f613503 to f1088d6 Compare May 28, 2024 21:45
@torrybr torrybr marked this pull request as ready for review May 28, 2024 21:51
@torrybr
Copy link
Author

torrybr commented May 28, 2024

@jplatte This has been revamped and should be ready for a second look if you have some spare time!

mars1999 and others added 4 commits June 2, 2024 09:54
Add missing even type to beacon handling

This is a work in progress.

move beacon struct to `beacon` module

wip

cleanup

make it compile; add test

ensure that location is enabled for beacon live sharing

use beacon_info instead of beacon for state event

cleanup

feat(beacon): add unstable support for msc-3489

feat(beacon): add unstable support for msc-3489

squash commits

refactor(beacon_info): rename files to be consistent with spec name

tests(beacon_info): Update beacon_info test for serialization and de_serialization

revert(pinnedevents): remove accdiental change

chore: update formatting

docs(beacon_info): update descriptions

clean up tests

refactor(beacon_info): update file naming and paths

feat(beacon): integrate beacon event with tests

test(beacon_info): fix broken test for creating asset type

refactor(beacon_info): update constructor params for owned_event_id and geo_uri

fix(enums): beacon info import fix

remove unused imports

fix(beacon_info): bad naming alias

fix(beacon_info): set the default ts time on creation

fix(beacon_info): fix tests for calculating expiration

remove some docs

docs(changelog): update changelog

fix clippy

use passed in value or now

fix clippy

fix tests

update docs

update correct changelog

revert changelog

revert changes

update changelog
@jplatte jplatte requested a review from a team June 4, 2024 08:57
crates/ruma-events/CHANGELOG.md Outdated Show resolved Hide resolved
crates/ruma-events/Cargo.toml Outdated Show resolved Hide resolved
crates/ruma-events/src/beacon.rs Outdated Show resolved Hide resolved
crates/ruma-events/src/beacon.rs Outdated Show resolved Hide resolved
crates/ruma-events/src/enums.rs Outdated Show resolved Hide resolved
crates/ruma-events/src/room/beacon_info.rs Outdated Show resolved Hide resolved
crates/ruma-events/tests/it/beacon.rs Outdated Show resolved Hide resolved
crates/ruma-events/tests/it/beacon_info.rs Outdated Show resolved Hide resolved
crates/ruma/Cargo.toml Outdated Show resolved Hide resolved
crates/ruma/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@zecakeh zecakeh left a comment

Choose a reason for hiding this comment

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

Thanks, just a few nits remaining.

crates/ruma-events/CHANGELOG.md Outdated Show resolved Hide resolved
crates/ruma-events/src/beacon.rs Show resolved Hide resolved
crates/ruma-events/src/beacon_info.rs Show resolved Hide resolved
crates/ruma-events/src/beacon.rs Outdated Show resolved Hide resolved
crates/ruma-events/src/beacon_info.rs Outdated Show resolved Hide resolved
crates/ruma-events/src/beacon_info.rs Outdated Show resolved Hide resolved
}

#[test]
fn beacon_info_start_event_content_serialization() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have tests of full event (BeaconInfoEvent) serialization and deserialization too?

}

#[test]
fn beacon_event_content_serialization() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have tests of full event (BeaconEvent) serialization and deserialization too?

Copy link
Author

@torrybr torrybr Jun 8, 2024

Choose a reason for hiding this comment

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

something like this? Not a complete example, just making sure this is what you are expecting generally

#[test]
fn message_event_deserialization() {
    let json_data = json!({
        "content": get_beacon_event_content_json(),
        "event_id": "$beacon_event_id:example.com",
        "origin_server_ts": 1_636_829_458,
        "room_id": "!roomid:example.com",
        "type": "org.matrix.msc3672.beacon",
        "sender": "@example:example.com"
    });

    let event = from_json_value::<AnyMessageLikeEvent>(json_data).unwrap();

    assert_matches!(event, AnyMessageLikeEvent::Beacon(MessageLikeEvent::Original(message_event)));
    assert_eq!(
        message_event.content.relates_to.event_id,
        owned_event_id!("$beacon_info_event_id:example.com")
    );
    assert_eq!(message_event.content.location.uri, "geo:51.5008,0.1247;u=35");
    assert_eq!(message_event.content.ts, MilliSecondsSinceUnixEpoch(uint!(1_636_829_458)));
    assert_matches!(message_event.content.relates_to, Reference { event_id, .. });

    assert_eq!(message_event.sender, "@example:example.com");
    assert_eq!(message_event.room_id, "!roomid:example.com");
    assert_eq!(message_event.event_id, owned_event_id!("$beacon_event_id:example.com"));
    assert_eq!(message_event.origin_server_ts, MilliSecondsSinceUnixEpoch(uint!(1_636_829_458)));
    assert!(message_event.unsigned.is_empty());
}

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

Successfully merging this pull request may close these issues.

None yet

4 participants