Set the user status when a mobile client polls for messages

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-09-23 14:38:49 +02:00
Родитель 9a7ff2471c
Коммит eea37cf12e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
2 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -42,9 +42,11 @@ use OCP\Collaboration\Collaborators\ISearchResult;
use OCP\Comments\IComment;
use OCP\Comments\MessageTooLongException;
use OCP\Comments\NotFoundException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\User\Events\UserLiveStatusEvent;
use OCP\UserStatus\IManager as IUserStatusManager;
use OCP\UserStatus\IUserStatus;
@ -86,6 +88,9 @@ class ChatController extends AEnvironmentAwareController {
/** @var ISearchResult */
private $searchResult;
/** @var IEventDispatcher */
private $eventDispatcher;
/** @var IL10N */
private $l;
/** @var ITimeFactory */
@ -104,6 +109,7 @@ class ChatController extends AEnvironmentAwareController {
IUserStatusManager $statusManager,
SearchPlugin $searchPlugin,
ISearchResult $searchResult,
IEventDispatcher $eventDispatcher,
ITimeFactory $timeFactory,
IL10N $l) {
parent::__construct($appName, $request);
@ -119,6 +125,7 @@ class ChatController extends AEnvironmentAwareController {
$this->statusManager = $statusManager;
$this->searchPlugin = $searchPlugin;
$this->searchResult = $searchResult;
$this->eventDispatcher = $eventDispatcher;
$this->timeFactory = $timeFactory;
$this->l = $l;
}
@ -267,6 +274,16 @@ class ChatController extends AEnvironmentAwareController {
]);
if ($isMobileApp && $this->participant->getInCallFlags() === Participant::FLAG_DISCONNECTED) {
$this->room->ping($this->participant->getUser(), $this->participant->getSessionId(), $this->timeFactory->getTime());
if ($lookIntoFuture) {
// Bump the user status again
$event = new UserLiveStatusEvent(
$this->userManager->get($this->participant->getUser()),
IUserStatus::ONLINE,
$this->timeFactory->getTime()
);
$this->eventDispatcher->dispatchTyped($event);
}
}
}

Просмотреть файл

@ -39,6 +39,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Collaboration\AutoComplete\IManager;
use OCP\Collaboration\Collaborators\ISearchResult;
use OCP\Comments\IComment;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUser;
@ -72,6 +73,8 @@ class ChatControllerTest extends TestCase {
protected $searchPlugin;
/** @var ISearchResult|MockObject */
protected $searchResult;
/** @var IEventDispatcher|MockObject */
protected $eventDispatcher;
/** @var ITimeFactory|MockObject */
protected $timeFactory;
/** @var IL10N|MockObject */
@ -100,6 +103,7 @@ class ChatControllerTest extends TestCase {
$this->statusManager = $this->createMock(IUserStatusManager::class);
$this->searchPlugin = $this->createMock(SearchPlugin::class);
$this->searchResult = $this->createMock(ISearchResult::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->l = $this->createMock(IL10N::class);
@ -130,6 +134,7 @@ class ChatControllerTest extends TestCase {
$this->statusManager,
$this->searchPlugin,
$this->searchResult,
$this->eventDispatcher,
$this->timeFactory,
$this->l
);