Browse Source

Merge pull request #1919 from nextcloud/bugfix/1841/allow-to-escapce-commands

Allow to escape commands
pull/1951/head
Joas Schilling 7 years ago
committed by GitHub
parent
commit
3a78f64382
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      lib/Chat/Command/Listener.php
  2. 4
      lib/Chat/Parser/UserMention.php
  3. 13
      tests/integration/features/chat/commands.feature

4
lib/Chat/Command/Listener.php

@ -63,6 +63,10 @@ class Listener {
/** @var self $listener */
$listener = \OC::$server->query(self::class);
if (strpos($message->getMessage(), '//') === 0) {
return;
}
try {
/** @var Command $command */
/** @var string $arguments */

4
lib/Chat/Parser/UserMention.php

@ -123,6 +123,10 @@ class UserMention {
}
}
if (strpos($message, '//') === 0) {
$message = substr($message, 1);
}
$chatMessage->setMessage($message, $messageParameters);
}

13
tests/integration/features/chat/commands.feature

@ -31,3 +31,16 @@ Feature: chat/commands
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| group room | users | participant1 | participant1-displayname | Message 2 | [] |
| group room | users | participant1 | participant1-displayname | Message 1 | [] |
Scenario: double slash escapes a command for everyone
Given user "participant1" creates room "group room"
| roomType | 2 |
| roomName | room |
And user "participant1" adds "participant2" to room "group room" with 200
When user "participant1" sends message "//help" to room "group room" with 201
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| group room | users | participant1 | participant1-displayname | /help | [] |
And user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| group room | users | participant1 | participant1-displayname | /help | [] |
Loading…
Cancel
Save