@@ -23,6 +23,7 @@ import { RoomMember } from "matrix-js-sdk/src/models/room-member";
2323import { EventType } from "matrix-js-sdk/src/@types/event" ;
2424import { ILocationContent , LocationAssetType , M_TIMESTAMP } from "matrix-js-sdk/src/@types/location" ;
2525import { makeLocationContent } from "matrix-js-sdk/src/content-helpers" ;
26+ import { M_BEACON } from "matrix-js-sdk/src/@types/beacon" ;
2627
2728import { _t } from "../../../languageHandler" ;
2829import dis from "../../../dispatcher/dispatcher" ;
@@ -158,32 +159,42 @@ const Entry: React.FC<IEntryProps> = ({ room, type, content, matrixClient: cli,
158159 </ div > ;
159160} ;
160161
161- const getStrippedEventContent = ( event : MatrixEvent ) : IContent => {
162+ const transformEvent = ( event : MatrixEvent ) : { type : string , content : IContent } => {
162163 const {
163164 // eslint-disable-next-line @typescript-eslint/no-unused-vars
164165 "m.relates_to" : _ , // strip relations - in future we will attach a relation pointing at the original event
165166 // We're taking a shallow copy here to avoid https://github.com/vector-im/element-web/issues/10924
166167 ...content
167168 } = event . getContent ( ) ;
168169
170+ // beacon pulses get transformed into static locations on forward
171+ const type = M_BEACON . matches ( event . getType ( ) ) ? EventType . RoomMessage : event . getType ( ) ;
172+
169173 // self location shares should have their description removed
170174 // and become 'pin' share type
171- if ( isLocationEvent ( event ) && isSelfLocation ( content as ILocationContent ) ) {
175+ if (
176+ ( isLocationEvent ( event ) && isSelfLocation ( content as ILocationContent ) ) ||
177+ // beacon pulses get transformed into static locations on forward
178+ M_BEACON . matches ( event . getType ( ) )
179+ ) {
172180 const timestamp = M_TIMESTAMP . findIn < number > ( content ) ;
173181 const geoUri = locationEventGeoUri ( event ) ;
174182 return {
175- ...content ,
176- ...makeLocationContent (
177- undefined , // text
178- geoUri ,
179- timestamp || Date . now ( ) ,
180- undefined , // description
181- LocationAssetType . Pin ,
182- ) ,
183+ type,
184+ content : {
185+ ...content ,
186+ ...makeLocationContent (
187+ undefined , // text
188+ geoUri ,
189+ timestamp || Date . now ( ) ,
190+ undefined , // description
191+ LocationAssetType . Pin ,
192+ ) ,
193+ } ,
183194 } ;
184195 }
185196
186- return content ;
197+ return { type , content } ;
187198} ;
188199
189200const ForwardDialog : React . FC < IProps > = ( { matrixClient : cli , event, permalinkCreator, onFinished } ) => {
@@ -193,7 +204,7 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
193204 cli . getProfileInfo ( userId ) . then ( info => setProfileInfo ( info ) ) ;
194205 } , [ cli , userId ] ) ;
195206
196- const content = getStrippedEventContent ( event ) ;
207+ const { type , content } = transformEvent ( event ) ;
197208
198209 // For the message preview we fake the sender as ourselves
199210 const mockEvent = new MatrixEvent ( {
@@ -293,7 +304,7 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
293304 < Entry
294305 key = { room . roomId }
295306 room = { room }
296- type = { event . getType ( ) }
307+ type = { type }
297308 content = { content }
298309 matrixClient = { cli }
299310 onFinished = { onFinished }
0 commit comments