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

Fix bad content types when sending unencrypted media event with additional content data #7519

Merged
merged 1 commit into from
Nov 4, 2022

Conversation

Florian14
Copy link
Contributor

@Florian14 Florian14 commented Nov 3, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Fix incorrect type of event content entries when sending unencrypted events related to media files

Motivation and context

After uploading a media file (eg. voice message), the local event related to the media is updated with some metadata (eg. size). The event entity was retrieved from the database and mapped to the Event model without casting the json numbers to their original type.

Here is the issue, after retrieving some additional data, the entity was updated with the new metadata plus the additional data, with the wrong number types, causing an error when sending the event to the server.

This PR forces the cast of the json number before updating the event in the database.

Note: the issue is only visible on voice broadcast because additional data are added to the voice message events triggering a specific code to retrieve the additional data after uploading the voice message file.

Screenshots / GIFs

Before:
Event(type=m.room.message, eventId=$xxx, content={msgtype=m.audio, body=Voice Broadcast Part (2).mp4, info={mimetype=video/mp4, size=11275.0, duration=3413.0}, url=xxx, m.relates_to={rel_type=m.reference, event_id=$xxx}, org.matrix.msc1767.audio={duration=3413.0}, org.matrix.msc3245.voice={}, io.element.voice_broadcast_chunk={sequence=2.0}}, prevContent=null, originServerTs=1667415437377, senderId=@xxx:matrix.org, stateKey=null, roomId=!xxx:matrix.org, unsignedData=UnsignedData(age=null, redactedEvent=null, transactionId=$xxx, prevContent=null, relations=null, replacesState=null), redacts=null)
After:
Event(type=m.room.message, eventId=$xxx, content={msgtype=m.audio, body=Voice Broadcast Part (2).mp4, info={mimetype=video/mp4, size=11275, duration=3413}, url=xxx, m.relates_to={rel_type=m.reference, event_id=$xxx}, org.matrix.msc1767.audio={duration=3413}, org.matrix.msc3245.voice={}, io.element.voice_broadcast_chunk={sequence=2}}, prevContent=null, originServerTs=1667415437377, senderId=@xxx:matrix.org, stateKey=null, roomId=!xxx:matrix.org, unsignedData=UnsignedData(age=null, redactedEvent=null, transactionId=$xxx, prevContent=null, relations=null, replacesState=null), redacts=null)

Tests

  • Start a voice broadcast in an unencrypted room
  • Pause or stop the voice broadcast to send a voice message (or wait at least 120s)
  • Verify that there is no "failed to send" error

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@Florian14 Florian14 force-pushed the bugfix/fre/unencrypted_media_event_json_type branch from d5dbba4 to c0ba2f2 Compare November 3, 2022 10:29
@Florian14 Florian14 requested review from a team, bmarty and jmartinesp and removed request for a team and bmarty November 3, 2022 10:29
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

I haven't seen any "failed to send" or similar messages in the logs, so I guess it's fine.

@Florian14 Florian14 merged commit ac0d823 into develop Nov 4, 2022
@Florian14 Florian14 deleted the bugfix/fre/unencrypted_media_event_json_type branch November 4, 2022 09:40
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.

2 participants