Mattermost-server: Extend EnsureBot helper function to include bot images

Created on 16 Aug 2019  路  5Comments  路  Source: mattermost/mattermost-server

Bots may have a profle image and an icon that will show in the LHS of the webapp. The api offers separate calls to add these after bot creation.

The EnsureBot helper function currently creates a bot user and should be extended to be able to create one that includes given profile and/or icon images.

The proposal is to extend EnsureBot that will could also receive relative paths to the plugin folder of an icon and/or profile images which will load and pass to the api to set them respectively. This can be implemented using functional options through a EnsureBotWithOptions(*Bot, 鈥ptions) where Options could start by having the relative path for the profile image and one for the bot image.


If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.

New contributors please see our Developer's Guide.

JIRA: https://mattermost.atlassian.net/browse/MM-17297

AreToolkit Easy Help Wanted PR Exists TecGo

Most helpful comment

@ali-farooq0 That makes sense, thanks again. I'll take a look at some of the existing validation.

All 5 comments

I would like to pick this up if possible.

Thanks @alxsah 馃帀

Apologies if this is a stupid question - could someone please clarify which format the images would be in, and whether they would have fixed dimensions?

I'm trying to understand whether any formatting/resizing of the images would be needed before passing them to the API. Thanks.

Apologies if this is a stupid question - could someone please clarify which format the images would be in, and whether they would have fixed dimensions?

@alxsah the bot icon image is supposed to be svg format, any other formatting is rejected when setting the icon for a bot.
For profile image, I believe it can be any common image format png, jpeg you can see the setProfileImage api to see the validation there.

I'm trying to understand whether any formatting/resizing of the images would be needed before passing them to the API. Thanks.

Nope, the underlying api should take care of that, if not, then maybe we should add validation in a common spot so the underlying api does validation for however it is invoked. Otherwise you can just do the same validation as https://github.com/mattermost/mattermost-server/blob/master/app/user.go#L874 for the profile image.

Hope this helps :)

@ali-farooq0 That makes sense, thanks again. I'll take a look at some of the existing validation.

Was this page helpful?
0 / 5 - 0 ratings