GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Refactor Matrix media operations by radaljj · Pull Request #107 · OpenResilienceInitiative/ORISO-UserService

Conversation

@radaljj

@radaljj radaljj commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extracted Matrix media upload/download logic from MatrixSynapseService into a new focused MatrixMediaClient.
  • Kept MatrixSynapseService as the existing public entry point, so current callers/controllers remain unchanged.
  • Moved file upload, file download, and file-message sending logic into the new media client.
  • Added focused unit coverage for Matrix media upload/download behavior.

Testing

  • mvn -DskipTests -Dspotless.check.skip=true compile
  • mvn -Dtest=MatrixMediaClientTest -Dspotless.check.skip=true test
  • mvn spotless:check

Notes

  • Refactor only.
  • No API changes.
  • No database changes.
  • No intended Matrix behavior changes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@radaljj
Refactor Matrix media operations
6608f31
@radaljj
radaljj requested a review from shazia-k June 13, 2026 10:32
@coderabbitai

coderabbitai Bot commented Jun 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 48512ee0-733a-46e5-bf21-e59d4413ba15

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/matrix-synapse-service-slice

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shazia-k
[fix]: Missing NPE and added more tests
168477f
@shazia-k

shazia-k commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

@radaljj
I found some missing scenarios and missing tests which I have completed
Here is the summary of changes I made

Review Summary
MatrixMediaClient.java — Issues Found & Fixed

Issue
1
NPE: file.getContentType() can return null → MediaType.parseMediaType(null) throws InvalidMediaTypeException
🔴 Bug
Fix:
Default to MediaType.APPLICATION_OCTET_STREAM when content type is null

2
NPE: file.getOriginalFilename() can return null → Map.of(...) throws NullPointerException for null values
🔴 Bug
Fix:
Default to "file" when original filename is null

3
Double exception wrapping — the inner throw new RuntimeException("No content_uri…") was caught by the outer catch (Exception e) and re-wrapped
🟡 Code smell
Fix:
Left as-is (message remains descriptive; cause chain is preserved)

4
sendFileMessage return value never used — method returned Map<String, Object> but the caller discarded it; the error branch returned a stale error map
🟡 Code smell
fix:
Changed return type to void; removed the meaningless error return

5
sendFileMessage failures silently masked as success — upload returns {success: true} even when the room message PUT fails
🟡 Design note
Fix:
Documented via the new test uploadFile_Should_StillReturnSuccess_When_SendFileMessageFails

6
Raw Map type on RestTemplate calls
🟢 Warning
Fix:
Added @SuppressWarnings("rawtypes") at the call sites

7
downloadFile try/catch over-broad structure — inner RuntimeException thrown and immediately re-caught
🟡 Code smell
Fix:
Restructured: network call inside try-catch, null-body check moved outside

MatrixMediaClientTest.java — Missing Tests Added (10 new, 12 total)
New Test. Branch Covered
uploadFile_Should_ThrowException_When_ResponseBodyIsNull
Null response body from upload POST

uploadFile_Should_ThrowException_When_ContentUriIsMissing
Response body present but no content_uri key

uploadFile_Should_ThrowException_When_RestTemplateThrows
Network failure during upload

uploadFile_Should_UseImageMsgtype_When_FileIsImage
image/* → m.image msgtype

uploadFile_Should_UseVideoMsgtype_When_FileIsVideo
video/* → m.video msgtype

uploadFile_Should_UseAudioMsgtype_When_FileIsAudio
audio/* → m.audio msgtype

uploadFile_Should_UseFileMsgtype_When_FileHasGenericContentType
application/* → m.file msgtype

uploadFile_Should_StillReturnSuccess_When_SendFileMessageFails
sendFileMessage exception is swallowed; documents current behaviour

downloadFile_Should_ThrowException_When_ResponseBodyIsNull
Null response body from download GET

downloadFile_Should_ThrowException_When_RestTemplateThrows
Network failure during download

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

shazia-k
shazia-k approved these changes Jun 14, 2026
View reviewed changes
shazia-k added 2 commits June 14, 2026 11:53
@shazia-k
[fix]: Formatetr
38529b3
@shazia-k
[fix]: Formatetr
ab40459
@radaljj
radaljj merged commit 8ea0cdd into dev Jun 14, 2026
2 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@radaljj
radaljj deleted the refactor/matrix-synapse-service-slice branch June 14, 2026 10:52
@kiodreambau kiodreambau mentioned this pull request Jul 8, 2026
EPIC: Test quality offensive — CI gates, lint zero, contract diffs, E2E harness #336
Closed
@Storypapst Storypapst mentioned this pull request Jul 22, 2026
Refactor Matrix media operations #715
Closed
@Storypapst Storypapst mentioned this pull request Nov 1, 2026
feat(chat): members endpoint names each role; advice seekers read it only from inside the room (OBP 2.1 #107) #1536
Merged
shazia-k added a commit that referenced this pull request Nov 2, 2026
@shazia-k
Merge pull request #1536 from OpenResilienceInitiative/claude/obp-dev…
7580802
…-blockers-ync2mf-role-badges

feat(chat): members endpoint names each role; advice seekers read it only from inside the room (OBP 2.1 #107)
@Hassan9215 Hassan9215 mentioned this pull request Nov 5, 2026
Release UserService v2.0.15 #1602
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@shazia-k shazia-k shazia-k approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@radaljj @shazia-k
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.