Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.53k stars 2.88k forks source link

[$1000] Not able to upload svg image on chat but works well on profile picture #19499

Closed kavimuru closed 1 year ago

kavimuru commented 1 year ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Go to staging dot on web chrome
  2. First try to upload any svg image on profile picture and notice that it works well
  3. But now try to upload the same svg on chat composer and notice that it loads but doesn't upload and throws an error

Expected Result:

Able to upload svg image on chat in a similar way how it works well on the profile picture

Actual Result:

Not able to upload svg image on chat but works well on profile picture

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

Version Number: 1.3.17.1 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation

https://github.com/Expensify/App/assets/43996225/33691d28-6172-40da-99a0-3c21cee4aa52

https://github.com/Expensify/App/assets/43996225/e19b2925-aa36-435d-90f4-2976e231a5e5

Expensify/Expensify Issue URL: Issue reported by: @priya-zha Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1684685097227669

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01840b20615262c1d1
  • Upwork Job ID: 1661470294263726080
  • Last Price Increase: 2023-05-24
melvin-bot[bot] commented 1 year ago

Triggered auto assignment to @adelekennedy (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

melvin-bot[bot] commented 1 year ago

Triggered auto assignment to @abekkala (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

melvin-bot[bot] commented 1 year ago

Job added to Upwork: https://www.upwork.com/jobs/~01840b20615262c1d1

melvin-bot[bot] commented 1 year ago

Current assignee @abekkala is eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] commented 1 year ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia (External)

melvin-bot[bot] commented 1 year ago

Triggered auto assignment to @Gonals (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

AyoubMoujane commented 1 year ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

Unable to upload an svg image in chat even though it's possible to upload an svg to update the profile picture of the user.

What is the root cause of that problem?

The API commands used for the two actions are different:

The failure response of the API for AddAttachment looks like this:

Screenshot 2023-05-26 at 16 30 42

What changes do you think we should make in order to solve the problem?

Check the two API commands implementation and figure out if it makes sense to take part of the logic used to process the svg image from UpdateUserAvatar and share it with AddAttachment command.

What alternative solutions did you explore? (Optional)

Convert the svg image into a png client-side using a library but I think this logic should be handled on the backend

melvin-bot[bot] commented 1 year ago

📣 @AyoubMoujane! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
AyoubMoujane commented 1 year ago

Contributor details Your Expensify account email: moujane.ayoub@hotmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~0126293d99c814e8f5

melvin-bot[bot] commented 1 year ago

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

abekkala commented 1 year ago

@thesahindia will review proposals as they come in

c3024 commented 1 year ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

SVGs can be uploaded and submitted at profile photo but submitting at comments returns an error.

What is the root cause of that problem?

Lines 318 to 322 of App/src/components/AvatarCropModal/AvatarCropModal.js

        // Svg images are converted to a png blob to preserve transparency, so we need to update the
        // image name and type accordingly.
        const isSvg = props.imageType.includes('image/svg');
        const imageName = isSvg ? 'fileName.png' : props.imageName;
        const imageType = isSvg ? 'image/png' : props.imageType;

This SVG conversion to PNG is missing in the addAttachment here. Lines 863 to 871 of App/sec/pages/home/report/ReportActionCompose.js

    addAttachment(file) {
        // Since we're submitting the form here which should clear the composer
        // We don't really care about saving the draft the user was typing
        // We need to make sure an empty draft gets saved instead
        this.debouncedSaveReportComment.cancel();
        const comment = this.prepareCommentAndResetComposer();
        Report.addAttachment(this.props.reportID, file, comment);
        this.setTextInputShouldClear(false);
    }

What changes do you think we should make in order to solve the problem?

Check if the file is SVG and convert it to PNG in addAttachment with the logic used in AvatarCropModal.js. However, this would show png on the recipient end.

What other solutions did you explore?

  1. I think server side logic is preventing SVG images. It should be changed to prevent this error.
  2. Convert PNG to SVG again on client with a JS library but this would not be the exact same SVG sent by sender.
thesahindia commented 1 year ago

@abekkala, it is a backend issue. It needs to be internal.

cc: @Gonals

melvin-bot[bot] commented 1 year ago

Current assignee @thesahindia is eligible for the Internal assigner, not assigning anyone new.

Gonals commented 1 year ago

I'll take a closer look tomorrow!

Gonals commented 1 year ago

This seems to be working fine now both in staging and dev! Closing

priya-zha commented 1 year ago

@Gonals I'm still able to reproduce with SVG images. I have tried the below svg images. vote (1) sample_1280×853 1677239475mouse-rat

Gonals commented 1 year ago

You are right. Not sure why it worked with the one I had.

Gonals commented 1 year ago

SVG is not supported by getImageSize in PHP, so the only way to have it behave as an image (with its preview and whatnot) would be to change the format.

I think that, for attachment purposes, it'd be better to keep the file intact, displaying them as a link, like we do for documents or other files, instead of displaying the preview.

We can always change the code to show a PNG as the preview, but then download the actual file. In any case, that's some polish we can do down the line, but I'll wrap up a fix so we allow SVG attachments for now.

abekkala commented 1 year ago

@Gonals is there any update on the internal fix for this one?

abekkala commented 1 year ago

Oh! does this one require a payout? I see that the merged PR has gone to production but I'm not seeing any of the auto-updates irt payments??

abekkala commented 1 year ago

[$250] Payment to @priya-zha

abekkala commented 1 year ago

@priya-zha upwork contract offer sent: Payment Issue for E/App #19499 - Expensify

priya-zha commented 1 year ago

Offer accepted. Thanks

abekkala commented 1 year ago

payment made and contract ended - thank you! 🎉

abekkala commented 1 year ago

Confirmed with @Gonals: Internal fix and Internal PR review - no other payments needed