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

Attachment support #3

Merged
merged 8 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ php:
- 7.4

env:
- LARAVEL_VERSION=5.5.*
- LARAVEL_VERSION=5.6.*
- LARAVEL_VERSION=5.7.*
- LARAVEL_VERSION=5.8.*
Expand All @@ -17,7 +16,7 @@ install:


script:
- phpunit --coverage-text --coverage-clover=coverage.clover
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
Expand Down
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,89 @@ public function routeNotificationForRocketChat(): string

`content()`: Sets a content of the notification message. Supports Github flavoured markdown.

`alias()`: This will cause the message’s name to appear as the given alias, but your username will still display.

`emoji()`: This will make the avatar on this message be an emoji. (e.g. ":see_no_evil:")

`avatar()`: This will make the avatar use the provided image url.

`attachment()`: This will add an single attachment.

`attachments()`: This will add multiple attachments.

`clearAttachments()`: This will remove all attachments.


### Adding Attachment
There are several ways to add one ore more attachments to a message
```php
public function toRocketChat($notifiable)
{
return RocketChatMessage::create("Test message")
->to('channel_name') // optional if set in config
->from('webhook_token') // optional if set in config
->attachments([
RocketChatAttachment::create()->imageUrl('test'),
RocketChatAttachment::create(['image_url' => 'test']),
new RocketChatAttachment(['image_url' => 'test']),
[
'image_url' => 'test'
]
]);
}
```
#### Available methods


`color()`: The color you want the order on the left side to be, any value background-css supports.

`text()`: The text to display for this attachment, it is different than the message’s text.

`timestamp()`: Displays the time next to the text portion. ISO8601 Zulu Date or instance of any `\DateTime`

`thumbnailUrl()`: An image that displays to the left of the text, looks better when this is relatively small.

`messageLink()`: Only applicable if the ts is provided, as it makes the time clickable to this link.

`collapsed()`: Causes the image, audio, and video sections to be hiding when collapsed is true.

`author($name, $link, $icon)`: shortcut for author methods

`authorName()`: Name of the author.

`authorLink()`: Providing this makes the author name clickable and points to this link.

`authorIcon()`: Displays a tiny icon to the left of the Author’s name.

`title()`: Title to display for this attachment, displays under the author.

`titleLink()`: Providing this makes the title clickable, pointing to this link.

`titleLinkDownload()`: When this is true, a download icon appears and clicking this saves the link to file.

`imageUrl()`: The image to display, will be “big” and easy to see.

`audioUrl()`: Audio file to play, only supports what html audio does.

`videoUrl()`: Video file to play, only supports what html video does.

`fields()`: An array of Attachment Field Objects.
```php
[
[
'short' => false, // Whether this field should be a short field. Default: false
'title' => 'Title 1', //The title of this field. Required
'value' => 'Value 1' // The value of this field, displayed underneath the title value. Required
],
[
'short' => true,
'title' => 'Title 2',
'value' => 'Value 2'
],

];


## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
Expand Down
Loading