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: Attachments not collapsing when using incoming webhook #31318

Merged
merged 14 commits into from
Jan 3, 2024
Merged

fix: Attachments not collapsing when using incoming webhook #31318

merged 14 commits into from
Jan 3, 2024

Conversation

hardikbhatia777
Copy link
Contributor

@hardikbhatia777 hardikbhatia777 commented Dec 25, 2023

Proposed changes (including videos or screenshots)

Right now there has been a long-standing issue where attachments don't collapse even when "collapsed": true is specified. Collapse always initializes as null (doesn't consider the value from the incoming webhook).

Before: (regardless of specifying collapsed: true or collapsed: false)
image

After:

Untitled.video.-.Made.with.Clipchamp.9.mp4

Issue(s)

fix #29276

Steps to test or reproduce

  1. Create webhook
  2. Try to send a message containing an attachment
  3. Specify "collapsed": true
  4. The attachment should be collapsed but it's not.
  5. Specify "collapsed": false
  6. The attachment is not collapsed.

Further comments

curl -H "X-Auth-Token: my-token" \ -H "X-User-Id: my-id" \ -H "Content-type:application/json" \ https://localhost:3000/api/v1/chat.postMessage \ -d '{"channel":"#general","emoji":":smirk:","text":"Sample message","attachments":[{"collapsed":true,"color":"#abcdef","fields":[{"title":"test 1","value":"test 1 value"},{"title":"test 2","value":"test 2 value"}],"text":"test text","title":"test title","title_link":"https://youtube.com","ts":"2016-12-09T16:53:06.761Z"}]}'

This command can be used to test the modification

Copy link

changeset-bot bot commented Dec 25, 2023

🦋 Changeset detected

Latest commit: d000969

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/api-client Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/models Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Dec 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4d473bb) 49.34% compared to head (d000969) 49.35%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #31318      +/-   ##
===========================================
+ Coverage    49.34%   49.35%   +0.01%     
===========================================
  Files         3306     3307       +1     
  Lines        81287    81300      +13     
  Branches     16650    16650              
===========================================
+ Hits         40111    40128      +17     
+ Misses       36481    36478       -3     
+ Partials      4695     4694       -1     
Flag Coverage Δ
e2e 52.56% <100.00%> (+0.06%) ⬆️
e2e-api 40.66% <ø> (-0.02%) ⬇️
unit 76.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@debdutdeb
Copy link
Member

hm this may be one fix .. but probably not the ideal one. IIRC when i looked at this, there was an inconsistency in how collapsed was passed at different stages vs how it was read. Just a comment for now

@hardikbhatia777
Copy link
Contributor Author

hardikbhatia777 commented Dec 27, 2023

Fair enough, I was sorta hesitant to use nullish operator but it seemed like the only option at the time.

I think the inconsistency came from collapsed being declared explicitly as a parameter when it wasn't really required. The collapsed value is taken as input in sendMessage.js as a sort of intrinsic value for every attachment (just like every other argument), however it is redeclared in the Attachments.tsx file for some reason. I tried to verify further effects of the same but it does seem like the redeclaration is redundant - it was always just assuming null value initially so all attachments were always uncollapsed.

Long story short, the type defined in Attachments.tsx need not redeclare collapsed. This should be the optimal solution imo, check it out whenever you have time @debdutdeb

PS. ignore the commit history :P

Copy link
Contributor

@hugocostadev hugocostadev left a comment

Choose a reason for hiding this comment

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

I read your considerations and I agree with your statment...

You can remove the prop from the type declaration and also from the component that is passing the collapsed prop to

Quote component here: https://github.com/RocketChat/Rocket.Chat/blob/develop/apps/meteor/client/components/message/content/attachments/QuoteAttachment.tsx#L71

@hardikbhatia777
Copy link
Contributor Author

Perfect :) I've made the changes @hugocostadev

@casalsgh casalsgh added this to the 6.6 milestone Jan 3, 2024
@janainaCoelhoRocketchat
Copy link
Contributor

tested

@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jan 3, 2024
@dionisio-bot dionisio-bot bot removed the stat: ready to merge PR tested and approved waiting for merge label Jan 3, 2024
@casalsgh casalsgh added the stat: ready to merge PR tested and approved waiting for merge label Jan 3, 2024
@dionisio-bot dionisio-bot bot removed the stat: ready to merge PR tested and approved waiting for merge label Jan 3, 2024
@casalsgh casalsgh added the stat: ready to merge PR tested and approved waiting for merge label Jan 3, 2024
@kodiakhq kodiakhq bot merged commit 87bba6d into RocketChat:develop Jan 3, 2024
43 checks passed
@hardikbhatia777 hardikbhatia777 deleted the collapsefix branch January 5, 2024 13:22
gabriellsh added a commit that referenced this pull request Jan 5, 2024
…hideUi

* 'develop' of github.com:RocketChat/Rocket.Chat:
  chore: add gitpod config file for quick setup (#30921)
  feat: Allow user to set timeout of outgoing webhook (#31222)
  feat: added modal confirmation before pinning message (#31348)
  fix: not being able to access or create rooms with join code (#31270)
  chore: services changes on lifecycle methods + throw if svc is not available (#31375)
  test: bump playwright (#31376)
  i18n: update translations (#29462)
  i18n: adds video call translations for Persian language (#30406)
  regression: `AppRow` bundleIn verification (#31373)
  feat: Add Desktop PDF viewer (#31279)
  fix: Attachments not collapsing when using incoming webhook (#31318)
  chore: add aria-label to Select Inputs at Engagement Dashboard (#31249)
  fix: engagement dashboard timezone selector (#31248)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
communityPR stat: QA tested stat: ready to merge PR tested and approved waiting for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Message attachments not collapsed when 'collapsed: true' provided in v6.2.0
7 participants