From 9367c6fb1ef4eabe468583d33f0be8bdf8b9c35f Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Fri, 11 Mar 2022 11:40:29 +0100 Subject: [PATCH] add m.beacon_info.live from msc3672 Signed-off-by: Kerry Archibald --- spec/unit/content-helpers.spec.ts | 4 ++++ src/@types/beacon.ts | 3 +++ src/content-helpers.ts | 2 ++ 3 files changed, 9 insertions(+) diff --git a/spec/unit/content-helpers.spec.ts b/spec/unit/content-helpers.spec.ts index 039f704cf3b..d43148dc8d3 100644 --- a/spec/unit/content-helpers.spec.ts +++ b/spec/unit/content-helpers.spec.ts @@ -32,12 +32,14 @@ describe('Beacon content helpers', () => { it('create fully defined event content', () => { expect(makeBeaconInfoContent( 1234, + true, 'nice beacon_info', LocationAssetType.Pin, )).toEqual({ [M_BEACON_INFO.name]: { description: 'nice beacon_info', timeout: 1234, + live: true, }, [M_TIMESTAMP.name]: mockDateNow, [M_ASSET.name]: { @@ -49,6 +51,7 @@ describe('Beacon content helpers', () => { it('defaults timestamp to current time', () => { expect(makeBeaconInfoContent( 1234, + true, 'nice beacon_info', LocationAssetType.Pin, )).toEqual(expect.objectContaining({ @@ -59,6 +62,7 @@ describe('Beacon content helpers', () => { it('defaults asset type to self when not set', () => { expect(makeBeaconInfoContent( 1234, + true, 'nice beacon_info', // no assetType passed )).toEqual(expect.objectContaining({ diff --git a/src/@types/beacon.ts b/src/@types/beacon.ts index d46117dd374..ff3cf64d264 100644 --- a/src/@types/beacon.ts +++ b/src/@types/beacon.ts @@ -75,6 +75,9 @@ export type MBeaconInfoContent = { description?: string; // how long from the last event until we consider the beacon inactive in milliseconds timeout: number; + // true when this is a live location beacon + // https://github.com/matrix-org/matrix-spec-proposals/pull/3672 + live?: boolean; }; export type MBeaconInfoEvent = EitherAnd< diff --git a/src/content-helpers.ts b/src/content-helpers.ts index 9ab11d6c5ec..ce8aebf0af9 100644 --- a/src/content-helpers.ts +++ b/src/content-helpers.ts @@ -196,12 +196,14 @@ export const parseLocationEvent = (wireEventContent: LocationEventWireContent): export const makeBeaconInfoContent = ( timeout: number, + isLive?: boolean, description?: string, assetType?: LocationAssetType, ): MBeaconInfoEventContent => ({ [M_BEACON_INFO.name]: { description, timeout, + live: isLive, }, [M_TIMESTAMP.name]: Date.now(), [M_ASSET.name]: {