瀏覽代碼

Fix user_status heartbeat response

Signed-off-by: jld3103 <jld3103yt@gmail.com>
tags/v26.0.0beta1
jld3103 1 年之前
父節點
當前提交
1f49a56a98
沒有連結到貢獻者的電子郵件帳戶。

+ 7
- 7
apps/user_status/lib/Controller/HeartbeatController.php 查看文件

@@ -30,7 +30,7 @@ use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
@@ -70,16 +70,16 @@ class HeartbeatController extends OCSController {
* @NoAdminRequired
*
* @param string $status
* @return JSONResponse
* @return DataResponse
*/
public function heartbeat(string $status): JSONResponse {
public function heartbeat(string $status): DataResponse {
if (!\in_array($status, [IUserStatus::ONLINE, IUserStatus::AWAY], true)) {
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

$user = $this->userSession->getUser();
if ($user === null) {
return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
return new DataResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
}

$event = new UserLiveStatusEvent(
@@ -92,11 +92,11 @@ class HeartbeatController extends OCSController {

$userStatus = $event->getUserStatus();
if (!$userStatus) {
return new JSONResponse([], Http::STATUS_NO_CONTENT);
return new DataResponse([], Http::STATUS_NO_CONTENT);
}

/** @psalm-suppress UndefinedInterfaceMethod */
return new JSONResponse($this->formatStatus($userStatus->getInternal()));
return new DataResponse($this->formatStatus($userStatus->getInternal()));
}

private function formatStatus(UserStatus $status): array {

+ 1
- 1
apps/user_status/src/services/heartbeatService.js 查看文件

@@ -34,7 +34,7 @@ const sendHeartbeat = async (isAway) => {
const response = await HttpClient.put(url, {
status: isAway ? 'away' : 'online',
})
return response.data
return response.data.ocs.data
}

export {

+ 2
- 2
dist/user_status-menu.js
文件差異過大導致無法顯示
查看文件


+ 1
- 1
dist/user_status-menu.js.map
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存