Skip to content

Commit

Permalink
Merge pull request #9978 from nextcloud/bugfix/9891/remove-threads-v1
Browse files Browse the repository at this point in the history
fix(chat)!: Remove threads v1 API changes
  • Loading branch information
nickvergessen authored Jul 17, 2023
2 parents 4f9a3fc + d5adfdf commit 6714e9b
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 88 deletions.
1 change: 0 additions & 1 deletion docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,3 @@
* `typing-privacy` - Support toggle typing privacy

## 18
* `threads` - Chat messages have a thread ID exposed which allows clients to only list chat messages of a dedicated messages stream
1 change: 0 additions & 1 deletion docs/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`: since Nextcloud 13
| field | type | Description |
|-----------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | int | ID of the comment |
| `threadId` | int | ID of the top most parent comment, indicating the thread of this message (`0` for the messages without a parent) (only available with `threads` capability) |
| `token` | string | Conversation token |
| `actorType` | string | See [Constants - Actor types of chat messages](constants.md#actor-types-of-chat-messages) |
| `actorId` | string | Actor id of the message author |
Expand Down
1 change: 0 additions & 1 deletion lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public function getCapabilities(): array {
'single-conversation-status',
'chat-keep-notifications',
'typing-privacy',
// FIXME Publish once the API is approved by the clients 'threads',
],
'config' => [
'attachments' => [
Expand Down
1 change: 0 additions & 1 deletion lib/Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public function toArray(string $format): array {

$data = [
'id' => (int) $this->getComment()->getId(),
'threadId' => (int) $this->getComment()->getTopmostParentId(),
'token' => $this->getRoom()->getToken(),
'actorType' => $this->getActorType(),
'actorId' => $this->getActorId(),
Expand Down
10 changes: 1 addition & 9 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2233,7 +2233,6 @@ protected function compareDataResponse(TableNode $formData = null) {
$includeReferenceId = in_array('referenceId', $formData->getRow(0), true);
$includeReactions = in_array('reactions', $formData->getRow(0), true);
$includeReactionsSelf = in_array('reactionsSelf', $formData->getRow(0), true);
$includeThreadId = in_array('threadId', $formData->getRow(0), true);

$expected = $formData->getHash();
$count = count($expected);
Expand All @@ -2243,10 +2242,6 @@ protected function compareDataResponse(TableNode $formData = null) {
$messages[$i]['messageParameters'] = 'IGNORE';
}

if ($includeThreadId && !is_numeric($expected[$i]['threadId'])) {
$expected[$i]['threadId'] = self::$textToMessageId[$expected[$i]['threadId']];
}

$result = preg_match('/POLL_ID\(([^)]+)\)/', $expected[$i]['messageParameters'], $matches);
if ($result) {
$expected[$i]['messageParameters'] = str_replace($matches[0], '"' . self::$questionToPollId[$matches[1]] . '"', $expected[$i]['messageParameters']);
Expand All @@ -2260,7 +2255,7 @@ protected function compareDataResponse(TableNode $formData = null) {
}
}

Assert::assertEquals($expected, array_map(function ($message) use ($includeParents, $includeReferenceId, $includeReactions, $includeReactionsSelf, $includeThreadId) {
Assert::assertEquals($expected, array_map(function ($message) use ($includeParents, $includeReferenceId, $includeReactions, $includeReactionsSelf) {
$data = [
'room' => self::$tokenToIdentifier[$message['token']],
'actorType' => $message['actorType'],
Expand All @@ -2287,9 +2282,6 @@ protected function compareDataResponse(TableNode $formData = null) {
$data['reactionsSelf'] = null;
}
}
if ($includeThreadId) {
$data['threadId'] = $message['threadId'];
}
return $data;
}, $messages));
}
Expand Down
Loading

0 comments on commit 6714e9b

Please sign in to comment.