Skip to content

fix: Attachments not collapsing when using incoming webhook - #31318

Merged
kodiakhq[bot] merged 14 commits into
RocketChat:developfrom
rezerov:collapsefix
Jan 3, 2024
Merged

fix: Attachments not collapsing when using incoming webhook#31318
kodiakhq[bot] merged 14 commits into
RocketChat:developfrom
rezerov:collapsefix

Conversation

@rezerov

@rezerov rezerov commented Dec 25, 2023

Copy link
Copy Markdown
Contributor

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

@rezerov
rezerov requested a review from a team as a code owner December 25, 2023 13:34
@changeset-bot

changeset-bot Bot commented Dec 25, 2023

Copy link
Copy Markdown

🦋 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

@codecov

codecov Bot commented Dec 25, 2023

Copy link
Copy Markdown

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
Copy Markdown
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

@rezerov

rezerov commented Dec 27, 2023

Copy link
Copy Markdown
Contributor Author

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

@hugocostadev hugocostadev left a comment

Copy link
Copy Markdown
Contributor

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

@rezerov

rezerov commented Dec 27, 2023

Copy link
Copy Markdown
Contributor Author

Perfect :) I've made the changes @hugocostadev

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

Copy link
Copy Markdown
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
@rezerov
rezerov 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

community 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