comments should compile mentions also if done by author

it is used by clients for formatting reasons, there is no reason not format
the author if her handle is included in the comment body.
It is unrelated to sending out notifications.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2018-01-17 13:48:43 +01:00
parent c121610d5a
commit 3784fa2074
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
2 changed files with 7 additions and 6 deletions

View File

@ -232,10 +232,6 @@ class Comment implements IComment {
$uids = array_unique($mentions[0]);
$result = [];
foreach ($uids as $uid) {
// exclude author, no self-mentioning
if($uid === '@' . $this->getActorId()) {
continue;
}
$result[] = ['type' => 'user', 'id' => substr($uid, 1)];
}
return $result;

View File

@ -8,6 +8,9 @@ use Test\TestCase;
class CommentTest extends TestCase {
/**
* @throws \OCP\Comments\IllegalIDChangeException
*/
public function testSettersValidInput() {
$comment = new Comment();
@ -58,6 +61,9 @@ class CommentTest extends TestCase {
$comment->setId('c17');
}
/**
* @throws \OCP\Comments\IllegalIDChangeException
*/
public function testResetId() {
$comment = new Comment();
$comment->setId('c23');
@ -133,7 +139,7 @@ class CommentTest extends TestCase {
'@alice @bob look look, a duplication @alice test @bob!', ['alice', 'bob']
],
[
'@alice is the author, but notify @bob!', ['bob'], 'alice'
'@alice is the author, notify @bob, nevertheless mention her!', ['alice', 'bob'], 'alice'
],
[
'@foobar and @barfoo you should know, @foo@bar.com is valid' .
@ -159,7 +165,6 @@ class CommentTest extends TestCase {
$uid = array_shift($expectedUids);
$this->assertSame('user', $mention['type']);
$this->assertSame($uid, $mention['id']);
$this->assertNotSame($author, $mention['id']);
}
$this->assertEmpty($mentions);
$this->assertEmpty($expectedUids);