mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
Return status of other user on one to one room
Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
parent
bc985aaa54
commit
2cd61fc9d9
6 changed files with 60 additions and 2 deletions
|
|
@ -113,3 +113,4 @@ title: Capabilities
|
|||
* `chat-get-context` - Whether the message context API endpoint is available
|
||||
* `config => call => breakout-rooms` - Whether breakout rooms are enabled on this instance
|
||||
* `config => call => recording` - Whether calls can be recorded (requires the High-performance backend server)
|
||||
* `single-conversation-status` - When the response of a single consersation return user status populated
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ class Capabilities implements IPublicCapability {
|
|||
'recording-v1',
|
||||
'avatar',
|
||||
'chat-get-context',
|
||||
'single-conversation-status'
|
||||
],
|
||||
'config' => [
|
||||
'attachments' => [
|
||||
|
|
|
|||
|
|
@ -332,8 +332,25 @@ class RoomController extends AEnvironmentAwareController {
|
|||
} catch (ParticipantNotFoundException $e) {
|
||||
}
|
||||
}
|
||||
$statuses = [];
|
||||
if ($this->userId !== null
|
||||
&& $this->appManager->isEnabledForUser('user_status')) {
|
||||
$userIds = array_filter(array_map(function (Room $room) {
|
||||
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
|
||||
$participants = json_decode($room->getName(), true);
|
||||
foreach ($participants as $participant) {
|
||||
if ($participant !== $this->userId) {
|
||||
return $participant;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}, [$room]));
|
||||
|
||||
return new DataResponse($this->formatRoom($room, $participant, [], $isSIPBridgeRequest), Http::STATUS_OK, $this->getTalkHashHeader());
|
||||
$statuses = $this->statusManager->getUserStatuses($userIds);
|
||||
}
|
||||
|
||||
return new DataResponse($this->formatRoom($room, $participant, $statuses, $isSIPBridgeRequest), Http::STATUS_OK, $this->getTalkHashHeader());
|
||||
} catch (RoomNotFoundException $e) {
|
||||
$response = new DataResponse([], Http::STATUS_NOT_FOUND);
|
||||
$response->throttle(['token' => $token]);
|
||||
|
|
|
|||
|
|
@ -1175,10 +1175,18 @@ class FeatureContext implements Context, SnippetAcceptingContext {
|
|||
* @param int $statusCode
|
||||
* @param string $apiVersion
|
||||
*/
|
||||
public function userGetsRoom(string $user, string $identifier, int $statusCode, string $apiVersion): void {
|
||||
public function userGetsRoom(string $user, string $identifier, int $statusCode, string $apiVersion = 'v4', TableNode $formData = null): void {
|
||||
$this->setCurrentUser($user);
|
||||
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier]);
|
||||
$this->assertStatusCode($this->response, $statusCode);
|
||||
|
||||
if ($formData instanceof TableNode) {
|
||||
$xpectedAttributes = $formData->getColumnsHash()[0];
|
||||
$actual = $this->getDataFromResponse($this->response);
|
||||
foreach ($xpectedAttributes as $attribute => $expectedValue) {
|
||||
Assert::assertEquals($expectedValue, $actual[$attribute]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -3254,6 +3262,19 @@ class FeatureContext implements Context, SnippetAcceptingContext {
|
|||
$this->assertStatusCode($this->response, $statusCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" set status to "([^"]*)" with (\d+)(?: \((v1)\))?$/
|
||||
*/
|
||||
public function setUserStatus(string $user, string $status, int $statusCode, string $apiVersion = 'v1'): void {
|
||||
$this->setCurrentUser($user);
|
||||
$this->sendRequest(
|
||||
'PUT',
|
||||
'/apps/user_status/api/' . $apiVersion . '/user_status/status',
|
||||
new TableNode([['statusType', $status]])
|
||||
);
|
||||
$this->assertStatusCode($this->response, $statusCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the response error matches with :error
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -67,3 +67,20 @@ Feature: chat/one-to-one
|
|||
Then user "participant1" sees the following messages in room "one-to-one room" with 200
|
||||
| room | actorType | actorId | actorDisplayName | message | messageParameters |
|
||||
| one-to-one room | users | participant2 | participant2-displayname | Message | [] |
|
||||
|
||||
Scenario: Return user status when get single conversation
|
||||
Given user "participant1" creates room "one-to-one room" (v4)
|
||||
| roomType | 1 |
|
||||
| invite | participant2 |
|
||||
When user "participant2" set status to "online" with 200 (v1)
|
||||
Then user "participant1" gets room "one-to-one room" with 200 (v4)
|
||||
| status |
|
||||
| online |
|
||||
When user "participant2" set status to "offline" with 200 (v1)
|
||||
Then user "participant1" gets room "one-to-one room" with 200 (v4)
|
||||
| status |
|
||||
| offline |
|
||||
Then user "participant2" set status to "away" with 200 (v1)
|
||||
Then user "participant1" gets room "one-to-one room" with 200 (v4)
|
||||
| status |
|
||||
| away |
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ class CapabilitiesTest extends TestCase {
|
|||
'recording-v1',
|
||||
'avatar',
|
||||
'chat-get-context',
|
||||
'single-conversation-status',
|
||||
'message-expiration',
|
||||
'reactions',
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue