Граф коммитов

70 Коммитов

Автор SHA1 Сообщение Дата
Joas Schilling 92a1af6596
Use a different object type for all the notifications
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-11-22 11:01:17 +01:00
Joas Schilling 335ad722c2
Mark mention notifications as read, when the user pulls the chat messages of the room
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-11-20 13:53:59 +01:00
Joas Schilling 2376d68d68
Also notify people which are in the call/room since they might not read the chat
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-11-20 12:09:36 +01:00
Joas Schilling af85b84388
Only notify participants when they are not active
Also removes notifications for public rooms where the user was not invited.

Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-11-20 10:38:39 +01:00
Daniel Calviño Sánchez c97c9c6b0e
Do not notify mentioned users that can not participate in the chat
Now mentioned users are notified only if they are already participants
of a private chat (a one to one chat, a group chat, or a password
protected public chat), or if the message was written in a public chat.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-11-20 10:38:39 +01:00
Daniel Calviño Sánchez 1e0bcabdeb
Add the message to the mention notifications
The chat message can be much longer than the maximum length allowed for
notification messages, so the notification message is trimmed if needed.

When the notification is being prepared to be displayed it is taken into
account if the message was trimmed, and in that case an ellipsis is
added at the start and/or the end (depending on the case) of the
message.

Note that the original notification message does not contain the
ellipsis characters, as depending on the language a whitespace should be
added or not before and after an ellipsis, and the language in which the
notification will be displayed is only known at the time of displaying
it, but not when it is saved.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-11-20 10:38:39 +01:00
Daniel Calviño Sánchez 1eb6cebcae
Add notifications for mentions in chat messages
When a user is mentioned in a chat message she will now receive a
notification about that. If a chat room is deleted all the pending
notifications will be also removed.

The rich subject of the notifications use "call" instead of "room" or
"chat" due to "call" being already available in
"lib/public/RichObjectStrings/Definitions.php" (in Nextcloud server),
although the Notifications app does not handle it in any special way
though ("apps/notifications/js/richObjectStringParser.js").

Note that, unlike with the current code for invitation notifications, no
checks are made on whether "call" is available or not, as the chat is
available only from Nextcloud 13 and onwards.

Currently every user mentioned in a chat message is notified, but this
will be tightened in later commits (for example, if a user is mentioned
in a chat room to which she is not able to join).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-11-20 10:38:38 +01:00
Joas Schilling c165e7c797
Fix unit tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-11-17 13:18:56 +01:00
Joas Schilling bf0ea8e775
Fix unit test
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-11-17 13:18:55 +01:00
Joas Schilling 995d6e4e55
Correctly join/exit the room in integration tests for calls
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-11-10 14:11:06 +01:00
Daniel Calviño Sánchez 41ab1d70cc
Fix integration tests for actions that just require being in a room
Since commit eae71a3977 a participant
(user or guest) can be in a room without joining a call; since then
sessions are no longer set and passwords are no longer checked when
joining a call, but when joining a room. Due to this some integration
tests had to be modified to join a room instead of a call.

Note, however, that in the modified tests there is no need to join a
call too once the participant has joined the room, as they either test
joining the room itself (the password tests) or the tested actions
simply need the participant to be in a room (the chat tests). Moreover,
in this later case, note that a participant is in a room if she created
a room, was invited to it or explicitly joined it, so the chat tests
involving a participant creating a room or inviting another one to it
did not need to be modified.

Finally, neither the call tests nor the "userJoinsCall" method from
FeatureContext were modified yet, as it has to be decided first whether
directly joining a call also joins the room automatically or not.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-11-10 11:44:22 +01:00
Joas Schilling f65d6f27a5
Change tables to talk_*
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-11-02 11:48:30 +01:00
Joas Schilling 5f11a47da0
Move old repair steps to migrations
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-11-02 11:48:30 +01:00
Joachim Bauch eb651eb869
Attempt to fix failing tests due to additional arguments.
Signed-off-by: Joachim Bauch <bauch@struktur.de>
2017-11-02 11:23:09 +01:00
Daniel Calviño Sánchez b18db10a1a Delete the chat messages of a room when the room is deleted
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-10-30 14:00:39 +01:00
Ivan Sein 9928c4d198 Merge pull request #444 from nextcloud/talk
Talk
2017-10-26 12:13:55 +02:00
Joas Schilling 68d7fd5e5c
Fix tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-10-25 11:36:40 +02:00
Daniel Calviño Sánchez ce9155289b Fix password protected rooms in chat backend
Before, any user was able to send and receive messages to and from
public password protected rooms, even if they were not invited and they
had not joined it; guests were not able to send, but were able to
receive nevertheless. Now, only invited users or users/guests that have
joined a public password protected room can send and receive messages to
and from it.

As a side effect that change affects too to regular public rooms (not
password protected), but the new behaviour makes more sense than the old
one anyway.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-10-20 03:49:07 +02:00
Daniel Calviño Sánchez 943a85d869 Use the room ID instead of the token as the object ID of chat comments
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-10-20 03:49:07 +02:00
Daniel Calviño Sánchez 0e29c7b39e Fix storing a spreed-session as an actorId
The character limit for actorId is 64, but the spreed-session is 256
characters long, so it has to be hashed to get an ID that fits.

The sha1 algorithm is used as, from all the hash functions bundled with
PHP that are always available (the Hash extension can be disabled using
the "--disable-hash" switch, unlike those that are part of the string
functions), it generates the longest hashes (40 characters) that fit in
the actorId column of the database.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-10-20 03:49:07 +02:00
Daniel Calviño Sánchez 2e73166dad Add integration tests for the chat
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-10-20 03:49:07 +02:00
Daniel Calviño Sánchez 9eb3611db5 Add controller for chat messages
The ChatController uses a long-polling approach: if there are currently
no messages the response will not be sent immediately; instead, HTTP
connection will be kept open waiting for new messages to arrive and,
when they do, then the response will be sent.

The technique is simply based on the fact that ChatManager will wait
(hang) until there are some messages to be returned, or until the
timeout expires.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-10-20 03:49:07 +02:00
Daniel Calviño Sánchez 4f0a97896e Add basic polling chat manager
The chat manager handles sending and receiving chat messages. It uses
basic polling; "receiveMessages()" will repeteadly query the database
for new messages, waiting a little between each query, until messages
are found or the timeout expires.

The Comments API is used internally, but as this class is meant to be
used directly and only by a Controller, "receiveMessages()" returns an
array of IComments too instead of a custom interface to save the
conversion of objects.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-10-20 03:49:07 +02:00
Joas Schilling bf979d31a0
Simplify activity and fix handling of deleted rooms
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-10-11 14:13:08 +02:00
Joas Schilling 5c1eac2080
Add more tests for invitations
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-10-11 12:12:41 +02:00
Joas Schilling a8b8ef1ee7
Fix unit tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-10-11 11:04:18 +02:00
Joas Schilling fb766fb1a5
Fix unit tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-09-29 11:56:22 +02:00
Ivan Sein 8e7b8320ce Merge pull request #363 from nextcloud/long-polling
Use an OCS controller and long polling instead of event sources
2017-09-26 11:30:42 +02:00
Joas Schilling 9448f73a7a
Fix integration tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-09-25 16:10:07 +02:00
Joas Schilling 288c1bb321
Fix spelling of Signaling (single L)
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-09-25 15:32:15 +02:00
Joas Schilling e0613c7330
Add integration tests for call handling with passwords
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-09-22 16:16:05 +02:00
Joas Schilling c8354fb250
Make sure join with password works :)
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-09-22 16:16:05 +02:00
Joas Schilling 87bfc885bd
Add integration tests for setting the password and joining without it
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-09-22 16:16:05 +02:00
Joas Schilling 14b9e85dac Merge pull request #415 from nextcloud/add-helper-script-to-run-integration-tests-on-a-docker-container
Add helper script to run integration tests on a Docker container
2017-09-22 11:50:50 +02:00
Joas Schilling 53574c0f98 Merge pull request #417 from nextcloud/use-a-different-display-name-than-the-user-id-in-the-integration-tests
Use a different display name than the user ID in the integration tests
2017-09-22 09:41:21 +02:00
Daniel Calviño Sánchez 7401193a92 Use a different display name than the user ID in the integration tests
This makes possible to ensure that the right value was returned by the
server.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-09-21 15:40:42 +02:00
Daniel Calviño Sánchez 6f10f84871 Fix Strict Standards error in integration tests on PHP 7
Besides returning the last element, "end" also sets the internal pointer
of the array to the last element, and for that it receives a reference
to the array. Thus, "end(array_keys(..." can not be used, as it would
generate the Strict Standards error "Only variables should be passed by
reference", so the returned value from "array_keys" has to be stored in
a variable.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-09-21 14:56:22 +02:00
Daniel Calviño Sánchez 06428a483f Add helper script to run integration tests on a Docker container
When running the integration tests through "run.sh" the parent directory
of the Spreed application must be the "apps" directory of an installed
Nextcloud server. Running the tests modifies the configuration and
database of that server, and the tests could fail too if the state of
its database conflicts with that expected by the tests.

The new "run-docker.sh" is a wrapper around "run.sh" that copies the
code (but not the configuration or data) of the Nextcloud server and its
applications to a Docker container, installs the Nextcloud server inside
the container (with a SQLite database), and then executes the
integration tests on the fresh server. This prevents the integration
tests from messing with the original Nextcloud server, and also ensures
that the integration tests will be run with a known initial state.

Besides that, when calling "run-docker.sh" the Docker image to be used
can be specified, so the tests can be easily run on PHP 5.6 or PHP 7.1
using "run-docker.sh --image nextcloudci/phpX.Y:phpX.Y-Z". If the
"--image" option is not given by default the image
"nextcloudci/php7.1:php7.1-15" will be used.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-09-21 13:55:47 +02:00
Daniel Calviño Sánchez ee58fbeb75 Fix integration tests on PHP 5.6
As stated in the documentation for "uasort", "if two members compare as
equal, their relative order in the sorted array is undefined". "uasort"
is used in "RoomController" to sort the participants of a room by their
last ping, so when two participants have the same last ping they could
be returned in any order.

Although undefined, the order is probably consistent (so, whatever the
order is, it is the same between different executions for the same
data). When using PHP 7 the participants are sorted in the same order
that currently appears in the integration test definitions. However, PHP
5.6 uses a different order, so the tests fail in that case.

This commit adds sorting of the participants in a room returned by the
server, so they can be checked against the expected participant list no
matter the order used by the server; the list is sorted by default, but
that behaviour can be prevented adding ` [exact order]` to the
participant list in a test definition, so the participant list can be
checked in the exact order returned by the server too (for example, if
needed to check the participant list after setting the last ping for
them).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-09-18 17:51:52 +02:00
Joas Schilling cf533647e7
Fix the signalling table
- Remove duplicate column
- Remove unneeded primary key
- Group deletion of messages into one query

Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-09-14 15:12:50 +02:00
Joas Schilling e781da77ce
Add unit tests for public calls
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 13:00:11 +02:00
Joas Schilling 17205cdeda
Call integration tests for one2one calls and group calls
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 12:53:58 +02:00
Joas Schilling e78243dea2
Add more integration tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 12:53:58 +02:00
Joas Schilling 2c942382ac
Start integration tests for public calls
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 12:53:58 +02:00
Joas Schilling e5c8ee5e64
Add integration tests for promotion/demotion
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 12:53:58 +02:00
Joas Schilling e3690002bd
Rename, make public and add participant
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 12:53:58 +02:00
Joas Schilling cdfe4b4d8e
Split integration tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 12:53:58 +02:00
Joas Schilling b4355a7ab5
Add integration tests for CallController
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 12:53:58 +02:00
Joas Schilling 1bfe3c847d
temp
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 12:53:57 +02:00
Joas Schilling 66ae76bbfd
Start to write some integration tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-08-07 12:53:54 +02:00