Skip to content

Commit

Permalink
Don't convert some symbols if they are part of a URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain committed Sep 18, 2019
1 parent c7f753d commit 084095b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Added

### Changed

[0.1.3] - 2019-09-18
--------------------

### Added

- API interface to send requests to the API

### Changed

- Improved the way we convert < and > symbols to make sure that link inclusion can work.

[0.1.2] - 2017-01-19
--------------------

Expand Down
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ In order to instantiate a connection to the API, you will need a token. You can

Each section of the [API documentation](https://api.slack.com/methods) has its own class with the corresponding methods.


### API

```php
use Strime\Slackify\Api\Api;

Expand All @@ -110,6 +113,8 @@ The following links will give you more details about the methods, specially abou
- [test](https://api.slack.com/methods/api.test)


### Auth

```php
use Strime\Slackify\Api\Auth;

Expand All @@ -124,6 +129,8 @@ The following links will give you more details about the methods:
- [test](https://api.slack.com/methods/auth.test)


### Bots

```php
use Strime\Slackify\Api\Bots;

Expand Down Expand Up @@ -176,6 +183,8 @@ The following links will give you more details about the methods:
- [unarchive](https://api.slack.com/methods/channels.unarchive)


### Chats

```php
use Strime\Slackify\Api\Chat;

Expand All @@ -194,6 +203,8 @@ The following links will give you more details about the methods:
- [update](https://api.slack.com/methods/chat.update)


### Dnd

```php
use Strime\Slackify\Api\Dnd;

Expand All @@ -214,6 +225,8 @@ The following links will give you more details about the methods:
- [teamInfo](https://api.slack.com/methods/dnd.teamInfo)


### Emoji

```php
use Strime\Slackify\Api\Emoji;

Expand All @@ -226,6 +239,8 @@ The following links will give you more details about the methods:
- [list](https://api.slack.com/methods/emoji.list)


### FilesComments

```php
use Strime\Slackify\Api\FilesComments;

Expand All @@ -242,6 +257,8 @@ The following links will give you more details about the methods:
- [edit](https://api.slack.com/methods/files.comments.edit)


### Files

```php
use Strime\Slackify\Api\Files;

Expand All @@ -264,6 +281,8 @@ The following links will give you more details about the methods:
- [upload](https://api.slack.com/methods/files.upload)


### Groups

```php
use Strime\Slackify\Api\Groups;

Expand Down Expand Up @@ -308,6 +327,8 @@ The following links will give you more details about the methods:
- [unarchive](https://api.slack.com/methods/groups.unarchive)


### Im

```php
use Strime\Slackify\Api\Im;

Expand All @@ -330,6 +351,8 @@ The following links will give you more details about the methods:
- [replies](https://api.slack.com/methods/im.replies)


### Mpim

```php
use Strime\Slackify\Api\Mpim;

Expand All @@ -352,6 +375,8 @@ The following links will give you more details about the methods:
- [replies](https://api.slack.com/methods/mpim.replies)


### Oauth

```php
use Strime\Slackify\Api\Oauth;

Expand All @@ -363,6 +388,9 @@ $api_oauth_request->access("client_id", "client_secret", "code", "https://www.fo
The following links will give you more details about the methods:
- [access](https://api.slack.com/methods/oauth.access)


### Pin

```php
use Strime\Slackify\Api\Pin;

Expand All @@ -378,6 +406,9 @@ The following links will give you more details about the methods:
- [list](https://api.slack.com/methods/pins.list)
- [remove](https://api.slack.com/methods/pins.remove)


### Reactions

```php
use Strime\Slackify\Api\Reactions;

Expand All @@ -395,6 +426,9 @@ The following links will give you more details about the methods:
- [list](https://api.slack.com/methods/reactions.list)
- [remove](https://api.slack.com/methods/reactions.remove)


### Reminders

```php
use Strime\Slackify\Api\Reminders;

Expand All @@ -414,6 +448,9 @@ The following links will give you more details about the methods:
- [info](https://api.slack.com/methods/reminders.info)
- [list](https://api.slack.com/methods/reminders.list)


### Rtm

```php
use Strime\Slackify\Api\Rtm;

Expand All @@ -425,6 +462,9 @@ $api_rtm_request->start(TRUE, FALSE, TRUE);
The following links will give you more details about the methods:
- [start](https://api.slack.com/methods/rtm.start)


### Search

```php
use Strime\Slackify\Api\Search;

Expand All @@ -440,6 +480,9 @@ The following links will give you more details about the methods:
- [files](https://api.slack.com/methods/search.files)
- [messages](https://api.slack.com/methods/search.messages)


### Stars

```php
use Strime\Slackify\Api\Stars;

Expand All @@ -455,6 +498,9 @@ The following links will give you more details about the methods:
- [list](https://api.slack.com/methods/stars.list)
- [remove](https://api.slack.com/methods/stars.remove)


### Team

```php
use Strime\Slackify\Api\Team;

Expand All @@ -474,6 +520,9 @@ The following links will give you more details about the methods:
- [integrationLogs](https://api.slack.com/methods/team.integrationLogs)
- [profile.get](https://api.slack.com/methods/team.profile.get)


### UserGroups

```php
use Strime\Slackify\Api\UserGroups;

Expand All @@ -497,6 +546,9 @@ The following links will give you more details about the methods:
- [users.list](https://api.slack.com/methods/usergroups.users.list)
- [users.update](https://api.slack.com/methods/usergroups.users.update)


### Users

```php
use Strime\Slackify\Api\Users;

Expand All @@ -521,6 +573,9 @@ The following links will give you more details about the methods:
- [setPhoto](https://api.slack.com/methods/users.setPhoto)
- [setPresence](https://api.slack.com/methods/users.setPresence)


### UsersProfile

```php
use Strime\Slackify\Api\UsersProfile;

Expand Down
10 changes: 5 additions & 5 deletions src/Strime/Slackify/Webhooks/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function sendMessage($values) {

// Parse the values to make sure they are valid
foreach ($values as $key => $value) {

// Create an array with the valid values
$valid_values = explode(",", self::SLACK_VALID_VALUES);

Expand All @@ -89,13 +89,13 @@ public function sendMessage($values) {

// Encode the message
$values["message"] = str_replace('&', '&amp;', $values["message"]);
$values["message"] = str_replace('<', '&lt;', $values["message"]);
$values["message"] = str_replace('>', '&gt;', $values["message"]);
$values["message"] = str_replace(' < ', ' &lt; ', $values["message"]);
$values["message"] = str_replace(' > ', ' &gt; ', $values["message"]);

// Add the link to the message if needed.
if (isset($values["link"]) && ($values["link"] !== NULL)) {
$values["message"] .= "\n";
$values["message"] .= "<" . $values["link"];
$values["message"] .= "<" . $values["link"];
if (isset($values["link_text"]) && ($values["link_text"] !== NULL)) {
$values["message"] .= "|" . $values["link_text"];
}
Expand Down Expand Up @@ -171,7 +171,7 @@ public function setAttachments($attachments)
// Browse the attachments to see if the key is valid.
foreach ($attachments as $attachment) {
foreach ($attachment as $key => $value) {

// Create an array with the valid values
$valid_values = explode(",", self::SLACK_VALID_ATTACHMENTS);

Expand Down

0 comments on commit 084095b

Please sign in to comment.