Skip to content

[NEW] Support for custom avatar images in channels#18443

Merged
sampaiodiego merged 41 commits intodevelopfrom
feat/channel-avatar
Aug 8, 2020
Merged

[NEW] Support for custom avatar images in channels#18443
sampaiodiego merged 41 commits intodevelopfrom
feat/channel-avatar

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented Jul 30, 2020

Proposed changes

Issue(s)

closes #18262

How to test or reproduce

Screenshots

image

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Hotfix (a major bugfix that has to be merged asap)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Changelog

Further comments

@ggazzo ggazzo added this to the 3.6.0 milestone Jul 30, 2020
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Jul 30, 2020

This pull request introduces 3 alerts when merging 25ec0ee into 55703f1 - view on LGTM.com

new alerts:

  • 3 for Unused variable, import, function or class

@MartinSchoeler
Copy link
Copy Markdown
Member

I can upload other file formats and break the server if i upload a .pdf this happens:
Screen Shot 2020-07-30 at 8 33 16 PM

and I get this error on the server console

W20200730-20:33:10.278(-3)? (STDERR) === UnHandledPromiseRejection ===
W20200730-20:33:10.279(-3)? (STDERR) [Error: Input file contains unsupported image format]
W20200730-20:33:10.279(-3)? (STDERR) ---------------------------------
W20200730-20:33:10.279(-3)? (STDERR) Errors like this can cause oplog processing errors.
W20200730-20:33:10.279(-3)? (STDERR) Setting EXIT_UNHANDLEDPROMISEREJECTION will cause the process to exit allowing your service to automatically restart the process
W20200730-20:33:10.279(-3)? (STDERR) Future node.js versions will automatically exit the process
W20200730-20:33:10.279(-3)? (STDERR) =================================

@MartinSchoeler
Copy link
Copy Markdown
Member

Also if this is done not from the admin view the saving fails and the browser gives this error:

Exception in setTimeout callback: TypeError: Cannot read property 'etag' of undefined
I20200730-20:44:02.133(-3)?     at app/lib/server/functions/setRoomAvatar.js:66:45
I20200730-20:44:02.139(-3)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
I20200730-20:44:02.140(-3)?     at packages/meteor.js:550:25
I20200730-20:44:02.140(-3)?     at runWithEnvironment (packages/meteor.js:1286:24)

no server crashes this time

…at into feat/channel-avatar

* 'feat/channel-avatar' of github.com:RocketChat/Rocket.Chat:
  Fix lint
@ggazzo ggazzo marked this pull request as ready for review July 31, 2020 20:27
Copy link
Copy Markdown
Member

@sampaiodiego sampaiodiego left a comment

Choose a reason for hiding this comment

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

@MartinSchoeler MartinSchoeler dismissed their stale review August 7, 2020 22:51

Now it's validating for allowed types!

@sampaiodiego sampaiodiego merged commit deecd73 into develop Aug 8, 2020
@sampaiodiego sampaiodiego deleted the feat/channel-avatar branch August 8, 2020 02:27
gabriellsh added a commit that referenced this pull request Aug 10, 2020
…omni

* 'develop' of github.com:RocketChat/Rocket.Chat:
  [NEW] Add REST API endpoint to search Livechat visitors (#18514)
  LingoHub based on develop (#18516)
  Update README.md (#18503)
  [NEW] Channel avatar (#18443)
  [FIX] Sending notifications from senders without a name (#18479)
  [FIX] UserCard avatar cache (avatarETag) (#18466)
  [IMPROVE] Admin Info page requires permission (#18408)
  [FIX] Marking room as read with unread threads still (#18410)
  [FIX] Random generated password not matching the Password Policy (#18475)
  Typo in privacy agreement message (#18476)
  bugfix for uploading files from livechat (#18474)
  LingoHub based on develop (#18465)
  [NEW] Add the ability to set the character message limit on Livechat widget (#18261)
  [FIX] Migration 194 (#18457)
  [FIX] Omnichannel session monitor is not starting (#18412)
  [FIX] Invalid MIME type when uploading audio files (#18426)
  [FIX] Error when updating omnichannel department without agents parameter (#18428)
  [FIX] Omnichannel Take Inquiry endpoint checking wrong permission (#18446)
  [FIX] Multiple push notifications sent via native drivers (#18442)
  [FIX] Appending 'false' to Jitsi URL (#18430)
@frdmn frdmn mentioned this pull request Aug 19, 2020
@Exordian
Copy link
Copy Markdown
Contributor

it seems like to wrong issue number was mentioned and an unrelated issue was closed

@rodrigok rodrigok changed the title [NEW] Channel avatar [NEW] Support for custom avatar images in channels Aug 24, 2020
@sampaiodiego
Copy link
Copy Markdown
Member

thanks for pointing it out @Exordian .. but the issue was indeed closed by this specific commit (ecd306c) included in this PR, although they seem unrelated 👍

@sampaiodiego sampaiodiego mentioned this pull request Aug 29, 2020
@inimatic
Copy link
Copy Markdown

In Directory search the avatars not shown.

@acceptMyPR
Copy link
Copy Markdown

acceptMyPR commented Sep 3, 2020

I install 3.6.0 and have this problem.

me too

@BjoernLudwig
Copy link
Copy Markdown

Also if this is done not from the admin view the saving fails and the browser gives this error:

In the logs of 3.7.1 the same error appears and as well only, when non-admins are trying to upload an avatar. For admins the feature works as expected.

@sampaiodiego
Copy link
Copy Markdown
Member

@BjoernLudwig
Copy link
Copy Markdown

@BjoernLudwigPTB you can test the release candidate for 3.8.0 .. https://github.com/RocketChat/Rocket.Chat/releases/tag/3.8.0-rc.5

Unfortunately I myself cannot. In my organisation I am only administrator on the application side, the deployment is done by colleagues. I asked them to have a look and will report.

@didacroyo
Copy link
Copy Markdown

It would be great to be able to set the custom Avatar via API, similarly to
/api/v1/users.setAvatar

image

@sampaiodiego
Copy link
Copy Markdown
Member

In theory you should be able to do that using the rooms.saveRoomSettings endpoint (which is not documented).. but I agree we having a rooms.setAvatar endpoint makes sense.. we're open for contributions =)

@didacroyo
Copy link
Copy Markdown

Hi Diego, thanks for your comment. You mean using an undocumented API REST endpoint or you mean the Realtime API? could you share an example call setting an avatarUrl to a rid? thanks

@sampaiodiego
Copy link
Copy Markdown
Member

@didacroyo you can do either.. there is an endpoint at /api/v1/rooms.saveRoomSettings that accepts the same payload as the Realtime Method called saveRoomSettings.. you can check the source code at

saveRoomSettings(rid, settings, value) {

you can send a payload with roomAvatar field which should work the same as using the users.setAvatar endpoint 😉

@jmessy919
Copy link
Copy Markdown

jmessy919 commented Mar 7, 2021

Just tried adding a channel icon to three different channels on the server. Only 1 time it worked. I am using the latest snap (3.10.5) on Ubuntu 20.04.2 LTS. Not sure why it doesn't work, as my manual installation of another RocketChat server (3.12.0, same droplet specs) never has an issue updating the channel icons. I have tried PNGs, GIFs, and JPGs on both the admin and user interface - nothing seems to work consistently.

EDIT: Apparently others on the server can see the channel icons, but not me even after refreshing and ignoring cache, outright closing RocketChat and starting it again, or rebooting the entire server. Odd.

@ArturoRejon
Copy link
Copy Markdown

Hi, @sampaiodiego

We are using our API to change the avatar of the rooms; but despite of all our efforts, it returns

{ "rid": "REAL_ROOM_ID", "success": true }

The response is 200 ok; but the avatar in the room isn't changed, even if we restart the service or reload without cache. We are sending this using PHP

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://OUR_CHAT/api/v1/rooms.saveRoomSettings',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
"rid": "REAL_ROOM_ID",
"roomAvatar":"VALID_IMAGE_URL"
}',
  CURLOPT_HTTPHEADER => array(
    'X-User-Id: REAL_ID_API',
    'X-Auth-Token: REAL_TOKEN',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

And we know that it somehow works, because we can send the key "roomName" and it successfully changes the name; but the image is never shown!!!

Thank you in advance for your help. Regards

@sampaiodiego
Copy link
Copy Markdown
Member

hi @ArturoRejon , I'm sorry the delay..

looks like the endpoint accepts a base64 for room avatar only, despite my previous comments and the documentation..

so instead of VALID_IMAGE_URL you'll need to parse the image content and provide a base64 payload, something like:

roomAvatar: "data:image/png;base64,iVBORw0KGg ...... "

@ArturoRejon
Copy link
Copy Markdown

@sampaiodiego thank you, it works!!

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.

[Bug] Hide system messages shows dropdown list only after second turn on