Skip to content
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
1 change: 0 additions & 1 deletion apps/user_status/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
'OCA\\UserStatus\\Migration\\Version0002Date20200902144824' => $baseDir . '/../lib/Migration/Version0002Date20200902144824.php',
'OCA\\UserStatus\\Migration\\Version1000Date20201111130204' => $baseDir . '/../lib/Migration/Version1000Date20201111130204.php',
'OCA\\UserStatus\\Migration\\Version2301Date20210809144824' => $baseDir . '/../lib/Migration/Version2301Date20210809144824.php',
'OCA\\UserStatus\\Service\\EmojiService' => $baseDir . '/../lib/Service/EmojiService.php',
'OCA\\UserStatus\\Service\\JSDataService' => $baseDir . '/../lib/Service/JSDataService.php',
'OCA\\UserStatus\\Service\\PredefinedStatusService' => $baseDir . '/../lib/Service/PredefinedStatusService.php',
'OCA\\UserStatus\\Service\\StatusService' => $baseDir . '/../lib/Service/StatusService.php',
Expand Down
1 change: 0 additions & 1 deletion apps/user_status/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ComposerStaticInitUserStatus
'OCA\\UserStatus\\Migration\\Version0002Date20200902144824' => __DIR__ . '/..' . '/../lib/Migration/Version0002Date20200902144824.php',
'OCA\\UserStatus\\Migration\\Version1000Date20201111130204' => __DIR__ . '/..' . '/../lib/Migration/Version1000Date20201111130204.php',
'OCA\\UserStatus\\Migration\\Version2301Date20210809144824' => __DIR__ . '/..' . '/../lib/Migration/Version2301Date20210809144824.php',
'OCA\\UserStatus\\Service\\EmojiService' => __DIR__ . '/..' . '/../lib/Service/EmojiService.php',
'OCA\\UserStatus\\Service\\JSDataService' => __DIR__ . '/..' . '/../lib/Service/JSDataService.php',
'OCA\\UserStatus\\Service\\PredefinedStatusService' => __DIR__ . '/..' . '/../lib/Service/PredefinedStatusService.php',
'OCA\\UserStatus\\Service\\StatusService' => __DIR__ . '/..' . '/../lib/Service/StatusService.php',
Expand Down
17 changes: 5 additions & 12 deletions apps/user_status/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,19 @@
*/
namespace OCA\UserStatus;

use OCA\UserStatus\Service\EmojiService;
use OCP\Capabilities\ICapability;
use OCP\IEmojiHelper;

/**
* Class Capabilities
*
* @package OCA\UserStatus
*/
class Capabilities implements ICapability {
private IEmojiHelper $emojiHelper;

/** @var EmojiService */
private $emojiService;

/**
* Capabilities constructor.
*
* @param EmojiService $emojiService
*/
public function __construct(EmojiService $emojiService) {
$this->emojiService = $emojiService;
public function __construct(IEmojiHelper $emojiHelper) {
$this->emojiHelper = $emojiHelper;
}

/**
Expand All @@ -54,7 +47,7 @@ public function getCapabilities() {
return [
'user_status' => [
'enabled' => true,
'supports_emoji' => $this->emojiService->doesPlatformSupportEmoji(),
'supports_emoji' => $this->emojiHelper->doesPlatformSupportEmoji(),
],
];
}
Expand Down
102 changes: 0 additions & 102 deletions apps/user_status/lib/Service/EmojiService.php

This file was deleted.

19 changes: 5 additions & 14 deletions apps/user_status/lib/Service/StatusService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\Exception;
use OCP\IConfig;
use OCP\IEmojiHelper;
use OCP\IUser;
use OCP\UserStatus\IUserStatus;

Expand All @@ -56,8 +57,7 @@ class StatusService {
/** @var PredefinedStatusService */
private $predefinedStatusService;

/** @var EmojiService */
private $emojiService;
private IEmojiHelper $emojiHelper;

/** @var bool */
private $shareeEnumeration;
Expand Down Expand Up @@ -95,24 +95,15 @@ class StatusService {
/** @var int */
public const MAXIMUM_MESSAGE_LENGTH = 80;

/**
* StatusService constructor.
*
* @param UserStatusMapper $mapper
* @param ITimeFactory $timeFactory
* @param PredefinedStatusService $defaultStatusService
* @param EmojiService $emojiService
* @param IConfig $config
*/
public function __construct(UserStatusMapper $mapper,
ITimeFactory $timeFactory,
PredefinedStatusService $defaultStatusService,
EmojiService $emojiService,
IEmojiHelper $emojiHelper,
IConfig $config) {
$this->mapper = $mapper;
$this->timeFactory = $timeFactory;
$this->predefinedStatusService = $defaultStatusService;
$this->emojiService = $emojiService;
$this->emojiHelper = $emojiHelper;
$this->shareeEnumeration = $config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
$this->shareeEnumerationInGroupOnly = $this->shareeEnumeration && $config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes';
$this->shareeEnumerationPhone = $this->shareeEnumeration && $config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no') === 'yes';
Expand Down Expand Up @@ -334,7 +325,7 @@ public function setCustomMessage(string $userId,
}

// Check if statusIcon contains only one character
if ($statusIcon !== null && !$this->emojiService->isValidEmoji($statusIcon)) {
if ($statusIcon !== null && !$this->emojiHelper->isValidSingleEmoji($statusIcon)) {
throw new InvalidStatusIconException('Status-Icon is longer than one character');
}
// Check for maximum length of custom message
Expand Down
12 changes: 6 additions & 6 deletions apps/user_status/tests/Unit/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
namespace OCA\UserStatus\Tests;

use OCA\UserStatus\Capabilities;
use OCA\UserStatus\Service\EmojiService;
use OCP\IEmojiHelper;
use Test\TestCase;

class CapabilitiesTest extends TestCase {

/** @var EmojiService|\PHPUnit\Framework\MockObject\MockObject */
private $emojiService;
/** @var IEmojiHelper|\PHPUnit\Framework\MockObject\MockObject */
private $emojiHelper;

/** @var Capabilities */
private $capabilities;

protected function setUp(): void {
parent::setUp();

$this->emojiService = $this->createMock(EmojiService::class);
$this->capabilities = new Capabilities($this->emojiService);
$this->emojiHelper = $this->createMock(IEmojiHelper::class);
$this->capabilities = new Capabilities($this->emojiHelper);
}

/**
Expand All @@ -50,7 +50,7 @@ protected function setUp(): void {
* @dataProvider getCapabilitiesDataProvider
*/
public function testGetCapabilities(bool $supportsEmojis): void {
$this->emojiService->expects($this->once())
$this->emojiHelper->expects($this->once())
->method('doesPlatformSupportEmoji')
->willReturn($supportsEmojis);

Expand Down
16 changes: 8 additions & 8 deletions apps/user_status/tests/Unit/Service/StatusServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
use OCA\UserStatus\Exception\InvalidStatusIconException;
use OCA\UserStatus\Exception\InvalidStatusTypeException;
use OCA\UserStatus\Exception\StatusMessageTooLongException;
use OCA\UserStatus\Service\EmojiService;
use OCA\UserStatus\Service\PredefinedStatusService;
use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\Exception;
use OCP\IConfig;
use OCP\IEmojiHelper;
use OCP\UserStatus\IUserStatus;
use Test\TestCase;

Expand All @@ -56,8 +56,8 @@ class StatusServiceTest extends TestCase {
/** @var PredefinedStatusService|\PHPUnit\Framework\MockObject\MockObject */
private $predefinedStatusService;

/** @var EmojiService|\PHPUnit\Framework\MockObject\MockObject */
private $emojiService;
/** @var IEmojiHelper|\PHPUnit\Framework\MockObject\MockObject */
private $emojiHelper;

/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
private $config;
Expand All @@ -71,7 +71,7 @@ protected function setUp(): void {
$this->mapper = $this->createMock(UserStatusMapper::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->predefinedStatusService = $this->createMock(PredefinedStatusService::class);
$this->emojiService = $this->createMock(EmojiService::class);
$this->emojiHelper = $this->createMock(IEmojiHelper::class);

$this->config = $this->createMock(IConfig::class);

Expand All @@ -84,7 +84,7 @@ protected function setUp(): void {
$this->service = new StatusService($this->mapper,
$this->timeFactory,
$this->predefinedStatusService,
$this->emojiService,
$this->emojiHelper,
$this->config);
}

Expand Down Expand Up @@ -138,7 +138,7 @@ public function testFindAllRecentStatusChangesNoEnumeration(): void {
$this->service = new StatusService($this->mapper,
$this->timeFactory,
$this->predefinedStatusService,
$this->emojiService,
$this->emojiHelper,
$this->config);

$this->assertEquals([], $this->service->findAllRecentStatusChanges(20, 50));
Expand All @@ -155,7 +155,7 @@ public function testFindAllRecentStatusChangesNoEnumeration(): void {
$this->service = new StatusService($this->mapper,
$this->timeFactory,
$this->predefinedStatusService,
$this->emojiService,
$this->emojiHelper,
$this->config);

$this->assertEquals([], $this->service->findAllRecentStatusChanges(20, 50));
Expand Down Expand Up @@ -519,7 +519,7 @@ public function testSetCustomMessage(string $userId,
->willThrowException(new DoesNotExistException(''));
}

$this->emojiService->method('isValidEmoji')
$this->emojiHelper->method('isValidSingleEmoji')
->with($statusIcon)
->willReturn($supportsEmoji);

Expand Down
3 changes: 2 additions & 1 deletion lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
'OCP\\IDBConnection' => $baseDir . '/lib/public/IDBConnection.php',
'OCP\\IDateTimeFormatter' => $baseDir . '/lib/public/IDateTimeFormatter.php',
'OCP\\IDateTimeZone' => $baseDir . '/lib/public/IDateTimeZone.php',
'OCP\\IEmojiHelper' => $baseDir . '/lib/public/IEmojiHelper.php',
'OCP\\IEventSource' => $baseDir . '/lib/public/IEventSource.php',
'OCP\\IGroup' => $baseDir . '/lib/public/IGroup.php',
'OCP\\IGroupManager' => $baseDir . '/lib/public/IGroupManager.php',
Expand Down Expand Up @@ -821,7 +822,6 @@
'OC\\Command\\FileAccess' => $baseDir . '/lib/private/Command/FileAccess.php',
'OC\\Command\\QueueBus' => $baseDir . '/lib/private/Command/QueueBus.php',
'OC\\Comments\\Comment' => $baseDir . '/lib/private/Comments/Comment.php',
'OC\\Comments\\EmojiHelper' => $baseDir . '/lib/private/Comments/EmojiHelper.php',
'OC\\Comments\\Manager' => $baseDir . '/lib/private/Comments/Manager.php',
'OC\\Comments\\ManagerFactory' => $baseDir . '/lib/private/Comments/ManagerFactory.php',
'OC\\Config' => $baseDir . '/lib/private/Config.php',
Expand Down Expand Up @@ -1089,6 +1089,7 @@
'OC\\Diagnostics\\QueryLogger' => $baseDir . '/lib/private/Diagnostics/QueryLogger.php',
'OC\\DirectEditing\\Manager' => $baseDir . '/lib/private/DirectEditing/Manager.php',
'OC\\DirectEditing\\Token' => $baseDir . '/lib/private/DirectEditing/Token.php',
'OC\\EmojiHelper' => $baseDir . '/lib/private/EmojiHelper.php',
'OC\\Encryption\\DecryptAll' => $baseDir . '/lib/private/Encryption/DecryptAll.php',
'OC\\Encryption\\EncryptionWrapper' => $baseDir . '/lib/private/Encryption/EncryptionWrapper.php',
'OC\\Encryption\\Exceptions\\DecryptionFailedException' => $baseDir . '/lib/private/Encryption/Exceptions/DecryptionFailedException.php',
Expand Down
3 changes: 2 additions & 1 deletion lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\IDBConnection' => __DIR__ . '/../../..' . '/lib/public/IDBConnection.php',
'OCP\\IDateTimeFormatter' => __DIR__ . '/../../..' . '/lib/public/IDateTimeFormatter.php',
'OCP\\IDateTimeZone' => __DIR__ . '/../../..' . '/lib/public/IDateTimeZone.php',
'OCP\\IEmojiHelper' => __DIR__ . '/../../..' . '/lib/public/IEmojiHelper.php',
'OCP\\IEventSource' => __DIR__ . '/../../..' . '/lib/public/IEventSource.php',
'OCP\\IGroup' => __DIR__ . '/../../..' . '/lib/public/IGroup.php',
'OCP\\IGroupManager' => __DIR__ . '/../../..' . '/lib/public/IGroupManager.php',
Expand Down Expand Up @@ -850,7 +851,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Command\\FileAccess' => __DIR__ . '/../../..' . '/lib/private/Command/FileAccess.php',
'OC\\Command\\QueueBus' => __DIR__ . '/../../..' . '/lib/private/Command/QueueBus.php',
'OC\\Comments\\Comment' => __DIR__ . '/../../..' . '/lib/private/Comments/Comment.php',
'OC\\Comments\\EmojiHelper' => __DIR__ . '/../../..' . '/lib/private/Comments/EmojiHelper.php',
'OC\\Comments\\Manager' => __DIR__ . '/../../..' . '/lib/private/Comments/Manager.php',
'OC\\Comments\\ManagerFactory' => __DIR__ . '/../../..' . '/lib/private/Comments/ManagerFactory.php',
'OC\\Config' => __DIR__ . '/../../..' . '/lib/private/Config.php',
Expand Down Expand Up @@ -1118,6 +1118,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Diagnostics\\QueryLogger' => __DIR__ . '/../../..' . '/lib/private/Diagnostics/QueryLogger.php',
'OC\\DirectEditing\\Manager' => __DIR__ . '/../../..' . '/lib/private/DirectEditing/Manager.php',
'OC\\DirectEditing\\Token' => __DIR__ . '/../../..' . '/lib/private/DirectEditing/Token.php',
'OC\\EmojiHelper' => __DIR__ . '/../../..' . '/lib/private/EmojiHelper.php',
'OC\\Encryption\\DecryptAll' => __DIR__ . '/../../..' . '/lib/private/Encryption/DecryptAll.php',
'OC\\Encryption\\EncryptionWrapper' => __DIR__ . '/../../..' . '/lib/private/Encryption/EncryptionWrapper.php',
'OC\\Encryption\\Exceptions\\DecryptionFailedException' => __DIR__ . '/../../..' . '/lib/private/Encryption/Exceptions/DecryptionFailedException.php',
Expand Down
Loading