Merge pull request #8057 from nextcloud/bugfix/8054/dont-search-lobbied-conversations

Don't search in lobbied conversations
This commit is contained in:
Joas Schilling 2022-09-30 22:13:20 +02:00 committed by GitHub
commit 40bbcdaa73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 279 additions and 171 deletions

View file

@ -121,34 +121,34 @@ local PipelinePostgreSQL(test_set) = Pipeline(
[
PipelineSQLite("callapi"),
PipelineSQLite("chat"),
PipelineSQLite("chat-2"),
PipelineSQLite("command"),
PipelineSQLite("conversation"),
PipelineSQLite("conversation-2"),
PipelineSQLite("federation"),
PipelineSQLite("integration"),
PipelineSQLite("reaction"),
PipelineSQLite("sharing"),
PipelineSQLite("sharing-2"),
PipelineMySQL("callapi"),
PipelineMySQL("chat"),
PipelineMySQL("chat-2"),
PipelineMySQL("command"),
PipelineMySQL("conversation"),
PipelineMySQL("conversation-2"),
PipelineMySQL("federation"),
PipelineMySQL("integration"),
PipelineMySQL("reaction"),
PipelineMySQL("sharing"),
PipelineMySQL("sharing-2"),
PipelinePostgreSQL("callapi"),
PipelinePostgreSQL("chat"),
PipelinePostgreSQL("chat-2"),
PipelinePostgreSQL("command"),
PipelinePostgreSQL("conversation"),
PipelinePostgreSQL("conversation-2"),
PipelinePostgreSQL("federation"),
PipelinePostgreSQL("integration"),
PipelinePostgreSQL("reaction"),
PipelinePostgreSQL("sharing"),
PipelinePostgreSQL("sharing-2"),
]

View file

@ -72,6 +72,42 @@ trigger:
- push
---
kind: pipeline
name: int-sqlite-chat-2
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
name: cache
steps:
- commands:
- bash tests/drone-run-integration-tests.sh || exit 0
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
- bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
- cd ../server
- ./occ app:enable $APP_NAME
- git clone --depth 1 -b $NOTIFICATIONS_BRANCH https://github.com/nextcloud/notifications
apps/notifications
- ./occ app:enable notifications
- cd apps/$APP_NAME
- composer --version
- composer self-update --2
- composer install
- cd tests/integration/
- bash run.sh features/chat-2
environment:
APP_NAME: spreed
CORE_BRANCH: master
DATABASEHOST: sqlite
GUESTS_BRANCH: master
NOTIFICATIONS_BRANCH: master
image: ghcr.io/nextcloud/continuous-integration-php8.0:latest
name: integration-chat-2
trigger:
branch:
- master
- stable*
event:
- push
---
kind: pipeline
name: int-sqlite-command
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
@ -254,42 +290,6 @@ trigger:
- push
---
kind: pipeline
name: int-sqlite-reaction
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
name: cache
steps:
- commands:
- bash tests/drone-run-integration-tests.sh || exit 0
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
- bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
- cd ../server
- ./occ app:enable $APP_NAME
- git clone --depth 1 -b $NOTIFICATIONS_BRANCH https://github.com/nextcloud/notifications
apps/notifications
- ./occ app:enable notifications
- cd apps/$APP_NAME
- composer --version
- composer self-update --2
- composer install
- cd tests/integration/
- bash run.sh features/reaction
environment:
APP_NAME: spreed
CORE_BRANCH: master
DATABASEHOST: sqlite
GUESTS_BRANCH: master
NOTIFICATIONS_BRANCH: master
image: ghcr.io/nextcloud/continuous-integration-php8.0:latest
name: integration-reaction
trigger:
branch:
- master
- stable*
event:
- push
---
kind: pipeline
name: int-sqlite-sharing
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
@ -464,6 +464,57 @@ trigger:
- push
---
kind: pipeline
name: int-mysql-chat-2
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
name: cache
- command:
- --innodb_large_prefix=true
- --innodb_file_format=barracuda
- --innodb_file_per_table=true
- --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
environment:
MYSQL_DATABASE: oc_autotest
MYSQL_PASSWORD: owncloud
MYSQL_ROOT_PASSWORD: owncloud
MYSQL_USER: oc_autotest
image: ghcr.io/nextcloud/continuous-integration-mariadb-10.4:10.4
name: mysql
tmpfs:
- /var/lib/mysql
steps:
- commands:
- bash tests/drone-run-integration-tests.sh || exit 0
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
- bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
- cd ../server
- ./occ app:enable $APP_NAME
- git clone --depth 1 -b $NOTIFICATIONS_BRANCH https://github.com/nextcloud/notifications
apps/notifications
- ./occ app:enable notifications
- cd apps/$APP_NAME
- composer --version
- composer self-update --2
- composer install
- cd tests/integration/
- bash run.sh features/chat-2
environment:
APP_NAME: spreed
CORE_BRANCH: master
DATABASEHOST: mysql
GUESTS_BRANCH: master
NOTIFICATIONS_BRANCH: master
image: ghcr.io/nextcloud/continuous-integration-php8.0:latest
name: integration-chat-2
trigger:
branch:
- master
- stable*
event:
- pull_request
- push
---
kind: pipeline
name: int-mysql-command
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
@ -721,57 +772,6 @@ trigger:
- push
---
kind: pipeline
name: int-mysql-reaction
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
name: cache
- command:
- --innodb_large_prefix=true
- --innodb_file_format=barracuda
- --innodb_file_per_table=true
- --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
environment:
MYSQL_DATABASE: oc_autotest
MYSQL_PASSWORD: owncloud
MYSQL_ROOT_PASSWORD: owncloud
MYSQL_USER: oc_autotest
image: ghcr.io/nextcloud/continuous-integration-mariadb-10.4:10.4
name: mysql
tmpfs:
- /var/lib/mysql
steps:
- commands:
- bash tests/drone-run-integration-tests.sh || exit 0
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
- bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
- cd ../server
- ./occ app:enable $APP_NAME
- git clone --depth 1 -b $NOTIFICATIONS_BRANCH https://github.com/nextcloud/notifications
apps/notifications
- ./occ app:enable notifications
- cd apps/$APP_NAME
- composer --version
- composer self-update --2
- composer install
- cd tests/integration/
- bash run.sh features/reaction
environment:
APP_NAME: spreed
CORE_BRANCH: master
DATABASEHOST: mysql
GUESTS_BRANCH: master
NOTIFICATIONS_BRANCH: master
image: ghcr.io/nextcloud/continuous-integration-php8.0:latest
name: integration-reaction
trigger:
branch:
- master
- stable*
event:
- pull_request
- push
---
kind: pipeline
name: int-mysql-sharing
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
@ -964,6 +964,51 @@ trigger:
- push
---
kind: pipeline
name: int-pgsql-chat-2
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
name: cache
- environment:
POSTGRES_DB: oc_autotest_dummy
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD: ""
POSTGRES_USER: oc_autotest
image: ghcr.io/nextcloud/continuous-integration-postgres-13:postgres-13
name: pgsql
tmpfs:
- /var/lib/postgresql/data
steps:
- commands:
- bash tests/drone-run-integration-tests.sh || exit 0
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
- bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
- cd ../server
- ./occ app:enable $APP_NAME
- git clone --depth 1 -b $NOTIFICATIONS_BRANCH https://github.com/nextcloud/notifications
apps/notifications
- ./occ app:enable notifications
- cd apps/$APP_NAME
- composer --version
- composer self-update --2
- composer install
- cd tests/integration/
- bash run.sh features/chat-2
environment:
APP_NAME: spreed
CORE_BRANCH: master
DATABASEHOST: pgsql
GUESTS_BRANCH: master
NOTIFICATIONS_BRANCH: master
image: ghcr.io/nextcloud/continuous-integration-php8.0:latest
name: integration-chat-2
trigger:
branch:
- master
- stable*
event:
- push
---
kind: pipeline
name: int-pgsql-command
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
@ -1191,51 +1236,6 @@ trigger:
- push
---
kind: pipeline
name: int-pgsql-reaction
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest
name: cache
- environment:
POSTGRES_DB: oc_autotest_dummy
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD: ""
POSTGRES_USER: oc_autotest
image: ghcr.io/nextcloud/continuous-integration-postgres-13:postgres-13
name: pgsql
tmpfs:
- /var/lib/postgresql/data
steps:
- commands:
- bash tests/drone-run-integration-tests.sh || exit 0
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
- bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
- cd ../server
- ./occ app:enable $APP_NAME
- git clone --depth 1 -b $NOTIFICATIONS_BRANCH https://github.com/nextcloud/notifications
apps/notifications
- ./occ app:enable notifications
- cd apps/$APP_NAME
- composer --version
- composer self-update --2
- composer install
- cd tests/integration/
- bash run.sh features/reaction
environment:
APP_NAME: spreed
CORE_BRANCH: master
DATABASEHOST: pgsql
GUESTS_BRANCH: master
NOTIFICATIONS_BRANCH: master
image: ghcr.io/nextcloud/continuous-integration-php8.0:latest
name: integration-reaction
trigger:
branch:
- master
- stable*
event:
- push
---
kind: pipeline
name: int-pgsql-sharing
services:
- image: ghcr.io/nextcloud/continuous-integration-redis:latest

View file

@ -27,6 +27,8 @@ use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Exceptions\UnauthorizedException;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Webinary;
use OCP\IUser;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
@ -87,6 +89,23 @@ class CurrentMessageSearch extends MessageSearch {
);
}
try {
$participant = $room->getParticipant($user->getUID(), false);
} catch (ParticipantNotFoundException $e) {
return SearchResult::complete(
$this->l->t('Messages'),
[]
);
}
if ($room->getLobbyState() !== Webinary::LOBBY_NONE &&
!($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) {
return SearchResult::complete(
$this->l->t('Messages'),
[]
);
}
$offset = (int) $query->getCursor();
$comments = $this->chatManager->searchForObjects(
$query->getTerm(),

View file

@ -31,6 +31,7 @@ use OCA\Talk\Exceptions\UnauthorizedException;
use OCA\Talk\Manager as RoomManager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Room;
use OCA\Talk\Webinary;
use OCP\Comments\IComment;
use OCP\IL10N;
use OCP\IURLGenerator;
@ -120,6 +121,13 @@ class MessageSearch implements IProvider {
continue;
}
if ($room->getLobbyState() !== Webinary::LOBBY_NONE) {
$participant = $room->getParticipant($user->getUID(), false);
if (!($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) {
continue;
}
}
$roomMap[(string) $room->getId()] = $room;
}

View file

@ -1930,6 +1930,27 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$this->compareDataResponse($formData);
}
/**
* @Then /^user "([^"]*)" searches for "([^"]*)" in room "([^"]*)" with (\d+)(?: \((v1)\))?$/
*
* @param string $user
* @param string $search
* @param string $identifier
* @param string $statusCode
* @param string $apiVersion
*/
public function userSearchesInRoom(string $user, string $search, string $identifier, $statusCode, string $apiVersion = 'v1', TableNode $formData = null): void {
$this->setCurrentUser($user);
$this->sendRequest('GET', '/search/providers/talk-message-current/search?term=' . $search . '&from=' . '/call/' . self::$identifierToToken[$identifier]);
$this->assertStatusCode($this->response, $statusCode);
if ($statusCode !== '200') {
return;
}
$this->compareSearchResponse($formData);
}
/**
* @Then /^user "([^"]*)" sees the following shared (media|audio|voice|file|deckcard|location|other) in room "([^"]*)" with (\d+)(?: \((v1)\))?$/
*
@ -2067,6 +2088,36 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}, $messages));
}
/**
* @param TableNode|null $formData
*/
protected function compareSearchResponse(TableNode $formData = null) {
$messages = $this->getDataFromResponse($this->response)['entries'];
if ($formData === null) {
Assert::assertEmpty($messages);
return;
}
$expected = array_map(static function (array $message) {
$message['attributes.conversation'] = self::$identifierToToken[$message['attributes.conversation']];
$message['attributes.messageId'] = self::$textToMessageId[$message['attributes.messageId']];
return $message;
}, $formData->getHash());
$count = count($expected);
Assert::assertCount($count, $messages, 'Message count does not match');
Assert::assertEquals($expected, array_map(static function ($message) {
return [
'title' => $message['title'],
'subline' => $message['subline'],
'attributes.conversation' => $message['attributes']['conversation'],
'attributes.messageId' => $message['attributes']['messageId'],
];
}, $messages));
}
/**
* @Then /^user "([^"]*)" sees the following system messages in room "([^"]*)" with (\d+)(?: \((v1)\))?$/
*

View file

@ -1,4 +1,4 @@
Feature: chat/notifications
Feature: callapi/notifications
Background:
Given user "participant1" exists

View file

@ -1,4 +1,4 @@
Feature: callapi/public
Feature: callapi/password
Background:
Given user "participant1" exists
And user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: chat/poll
Feature: chat-2/poll
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: chat/public-read-only
Feature: chat-2/public-read-only
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: chat/public
Feature: chat-2/public
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: reaction/react
Feature: chat-2/reaction
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: chat-2/read-status
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: chat/reference-id
Feature: chat-2/reference-id
Background:
Given user "participant1" exists

View file

@ -1,4 +1,4 @@
Feature: chat/reply
Feature: chat-2/reply
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: chat/public
Feature: chat-2/rich-messages
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: chat/public
Feature: chat-2/rich-object-share
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -0,0 +1,30 @@
Feature: chat-2/search
Background:
Given user "participant1" exists
Given user "participant2" exists
Scenario: Can not search when not a participant
Given user "participant1" creates room "room" (v4)
| roomType | 3 |
| roomName | room |
And user "participant1" sends message "Message 1" to room "room" with 201
When user "participant2" searches for "essa" in room "room" with 200
Scenario: Search for message when being a participant
Given user "participant1" creates room "room" (v4)
| roomType | 3 |
| roomName | room |
And user "participant1" adds user "participant2" to room "room" with 200 (v4)
And user "participant1" sends message "Message 1" to room "room" with 201
When user "participant2" searches for "essa" in room "room" with 200
| title | subline | attributes.conversation | attributes.messageId |
| participant1-displayname | Message 1 | room | Message 1 |
Scenario: Can not search when being blocked by the lobby
Given user "participant1" creates room "room" (v4)
| roomType | 3 |
| roomName | room |
And user "participant1" adds user "participant2" to room "room" with 200 (v4)
And user "participant1" sends message "Message 1" to room "room" with 201
And user "participant1" sets lobby state for room "room" to "non moderators" with 200 (v4)
When user "participant2" searches for "essa" in room "room" with 200

View file

@ -1,4 +1,4 @@
Feature: System messages
Feature: chat-2/system-messages
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: chat/unread-messages
Feature: chat-2/unread-messages
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: chat/reply
Feature: chat/delete
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: chat/public
Feature: chat/file-share
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: room/message-expiration
Feature: chat/message-expiration
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: create
Feature: command/create
Background:
Given user "participant1" exists

View file

@ -1,4 +1,4 @@
Feature: User remove
Feature: command/user-remove
Background:
Given user "participant1" exists

View file

@ -1,4 +1,4 @@
Feature: one-to-one
Feature: conversation-2/one-to-one
Background:
Given user "participant1" exists
Given user "participant2" exists
@ -206,4 +206,4 @@ Feature: one-to-one
| shareapi_restrict_user_enumeration_to_phone | yes |
And user "participant1" creates room "room15" with 403 (v4)
| roomType | 1 |
| invite | participant2 |
| invite | participant2 |

View file

@ -1,4 +1,4 @@
Feature: conversation/password-request
Feature: conversation-2/password-request
Background:
Given user "participant1" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation-2/promotion-demotion
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation-2/public-private
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation-2/remove-participant
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation-2/remove-self
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation-2/rename-room
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: set-description
Feature: conversation-2/set-description
Background:
Given user "owner" exists
Given user "moderator" exists

View file

@ -1,4 +1,4 @@
Feature: conversation/set-listable
Feature: conversation-2/set-listable
Background:
Given user "creator" exists
Given user "regular-user" exists

View file

@ -1,4 +1,4 @@
Feature: set-publishing-permissions
Feature: conversation-2/set-publishing-permissions
Background:
Given user "owner" exists
Given user "moderator" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation-2/set-password
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: set-publishing-permissions
Feature: conversation-2/set-publishing-permissions
Background:
Given user "owner" exists
Given user "moderator" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation-2/sip-dialin
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation/add-participant
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation/delete-room
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation/group-participants
Background:
Given user "participant1" exists
Given user "participant2" exists

View file

@ -1,4 +1,4 @@
Feature: public
Feature: conversation/limit-creation
Background:
Given user "participant1" exists
Given user "participant2" exists