EvotecIT / PSTeams

PSTeams is a PowerShell Module working on Windows / Linux and Mac. It allows sending notifications to Microsoft Teams via WebHook Notifications. It's pretty flexible and provides a bunch of options. Initially, it only supported one sort of Team Cards but since version 2.X.X it supports Adaptive Cards, Hero Cards, List Cards, and Thumbnail Cards. All those new cards have their own cmdlets and the old version of creating Teams Cards stays as-is for compatibility reasons.
MIT License
409 stars 41 forks source link

Support for custom activity images for New-TeamsSection #23

Closed R3ality closed 3 years ago

R3ality commented 4 years ago

Hey,

At shallow glance it appears there is currently no support for specifying a custom activity image for New-TeamsSection (apologies if I'm missing something).

While I appreciate the fact that there is a collection of activity images included by default within the module, feel it would be great value if users could specify custom images as well via either a file system path or a HTTP URL.

PS. Thank you for your efforts in developing and publishing this module!

PrzemyslawKlys commented 4 years ago

There are two parameters - ActivityImage and ActivityImageLink. You can push https links with images you want. There's no way to push ActivityImageLink as an embedded image - if that's what you're asking for. That would need to be added - however I didn't add it for a simple reason - the image size that is supported as embedded has to be really small making it really difficult to find good images.

R3ality commented 4 years ago

Thanks for a fast response.

Your concern regarding embedded images is valid, acceptable file size seems indeed rather limited (this is through trial and error, I'm not sure if the actual limit is specified in the documentation from Microsoft). Though, if it were a known value perhaps it could just be handled within the validation block (e.g. (Get-Item $path).length -gt $allowedByteSize or something similar)

Regardless, to fulfill the requirements for my intended use case I have made a somewhat quick and dirty adjustment to New-TeamsSection to add a param named ActivityImagePath which accepts file system paths.

I opened pull request https://github.com/EvotecIT/PSTeams/pull/24 for increased visibility but feel free to decline if it is subpar or against your intended design

PrzemyslawKlys commented 4 years ago

It's great. This would need to be added as part of: New-TeamsActivityImage as well. Also I guess we need to define parametersets within new-teams section otherwise it's possible people will try 3 options at the same time. Would you be able to fix it?

R3ality commented 4 years ago

I realized my original commit collided with the changes implemented in #22 so I reverted the assignation of $StoredImages to how it was before my changes. You'd have to verify your merging/publishing workflow still fixes it in case any changes to New-TeamsSection.ps1 and New-TeamsActivityImage.ps1 are accepted

R3ality commented 4 years ago

Added file system image path support to New-TeamsActivityImage as well and defined it as a separate parameter set as suggested (named "Path" in parallel to previously defined "Image" and "Link").

I did not implement parameter sets for New-TeamsSection however. This function did not have parameter sets beforehand (while already supporting both $ActivityImage and $ActivityImageLink) and I didn't feel comfortable adding them due to a large number of other params (which would need to be included in all 3 parameter sets). It is a valid point though so perhaps someone with more experience with parameter sets can take a swing at it.

As currently implemented if the user specifies all three parameters, they take precedence over one-another in the following order: $ActivityImagePath > $ActivityImage > $ActivityImageLink

Pending pull request should be up to date with the aforementioned