Before this PR, trying to get an available operator could result in an
error.
When a live chat is created, an operator is selected based on various
criteria such as language, country, number of ongoing chats and
availability for calls. This selection process involves the
`_get_less_active_operator` method, which receives the status of all
operators and a list of operators to choose from.
Prior to this fix, an operator not included in the list of operators
to choose from could still be selected, resulting in errors when
trying to locate them in the operator list.
This PR resolves the issue by ensuring that operators are only
selected from the provided list.
opw-3874872
closesodoo/odoo#162357
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this PR, the chatbot script would hang when redirected to a
page where the chatbot is not enabled.
When such a scenario occurs, we should restore the chatbot's state to
where it stopped, and the script should continue.
This PR fixes this issue.
task-3625853
closesodoo/odoo#161121
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Prior to this commit, the tour service would fail to observe changes
in the tour's shadow DOM after the tour was resumed.
A mutation observer waits for the shadow host to appear in the DOM,
then registers it with the macro engine observer in order for the
macro engine to take shadow DOM modifications into account.
This commit ensures that the same logic is applied when resuming a
tour.
Part-of: odoo/odoo#161121
Before this PR, the error displayed in the public page was quite
cryptic. It was hard for the user to understand that error and even
harder to report it if needed. This PR makes the error more user
friendly.
task-3850559
closesodoo/odoo#160947
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this PR, the external live chat templates contained useless
parts, residus of the old live chat implementation. This makes the
live chat code harder to understand and to maintain. This PR removes
those outdated parts.
task-3852092
closesodoo/odoo#137574
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
The `website_livechat.chatbot_redirect` tour checks that the chat bot
still works after redirection. The tour waits for the chat bot message
that indicates the redireciton was made. Since the tour restarts the
bot to test two differents flows, this message is already present
before the second redirection occurs. The tour should instead wait for
two occurences of this message the second time.
closesodoo/odoo#160296
X-original-commit: cfdcdc405751e2d8d81dbbec34894d3da9c005ef
Signed-off-by: Didier Debondt (did) <did@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this PR, the chat bot would stop after redirecting
a user on the same page that the current one (e.g. anchors)
because it was counting on the page reload that do not occur
in this case. This PR fixes the issue.
opw-3801598
closesodoo/odoo#159769
X-original-commit: 3d7c2b87e59b261a2d3eeceb0c6de012e8b02a2e
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
The push-to-talk extension service sends a message to the extension
when starting to check if it is enabled. If the response is received
before the RTC service is started, the answer is ignored, and the
service acts as if the extension were not available. This PR fixes
this issue.
closesodoo/odoo#158252
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the `test_websocket_instances_weak_set` was
sometimes failing. Indeed, this test doesn't wait for the connection
to be fully established before making its assertions. This commit
fixes this issue.
fixes runbot-55037,55035
closesodoo/odoo#157510
X-original-commit: 15bad5ccbeced41127eeaea3e47eebbc3f55091e
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
When a live chat starts with a bot, the channel name is missing the
operator and the visitor name. This makes it challenging for live chat
managers to review the session history.
This PR resolves the issue by updating the channel name when an
operator is found.
closesodoo/odoo#157385
X-original-commit: 725316e22f52780c7c96aedebbd9f5c4700bb3b2
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Co-authored-by: Matthieu Stockbauer <48757558+tsm-odoo@users.noreply.github.com>
The live chat should always be on top of other elements: some sites
that embeds it use z-index for various purposes. Currently, the live
chat does not uses z-index, thus is it can be hidden by other
elements.
This PR sets the z-index to the largest value handled by the browser.
opw-3732033
closesodoo/odoo#155903
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this PR, the `bus subscription is refreshed when channel is
left` test was sometimes failing. This actually reveals a real issue:
if a channel is joined a leave very quickly, the bus subscription is
not updated.
This occurs because we rely on the last subscription made and the one
that should be made to detect if channels differ. Since the
`updateBusSubscription` method is debounced, we can miss information.
This PR replaces the complicated `updateBusSubscription` method by a
`onAdd/onDelete`. This is much more reliable and more efficient since
there is no need to walk through every channel to detect changes.
This PR also remove a test that was redundant that the failing one.
fixes runbot-55292,57645,56232
closesodoo/odoo#155720
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
When a message is posted, the server sends a `mail.record/insert`
notification to update the related channel pin state. In order to
recognize the thread, the client needs its id and its model.
Currently, only the id is passed so the thread pin state is not
updated. This PR adds the model to the notification.
closesodoo/odoo#155150
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
*: mail.
This PR removes the live chat sidebar category. From now on, each
channel will have its own category. This is a first step towards
providing an efficient way for operators to join/leave a live chat
channel.
part of task-3640730
closesodoo/odoo#154755
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this commit, an Odoo dialog would open to show errors that
occurred in the pages embedding the live chat. We should not display
errors originating from outside the embedded script. Moreover, the
error service listens to the error event on the window object. Thus,
errors occurring in the shadow DOM won't be caught. As a result, the
error service disrupts the site that embeds it and is entirely useless
for the live chat.
This PR removes the error service from the embedded live chat.
OPW-3699040
closesodoo/odoo#154102
X-original-commit: 24b6b7a43748b5f1053aa7c70dc7046dbc894c7f
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Since 16.3, opening the web client on the Odoo backends results in two
subscribe events being sent through the bus websocket.
Discuss listens to the thread changes to know when the subscription
should be refreshed. In order to do so, the last subscription that was
made is kept. This issue is that this subscription is empty in the
first place so the first evaluation always considers the subscription
should be made.
In order to fix this issue, this PR refine the condition to determine
if the subscription should be renewed:
- The last subscription is different from the last one
- The user joined a channel after the bus initialization
- The user left a channel after the bus initialization
In order to test those scenario in a reliable way, this PR also
backports odoo#147455
closesodoo/odoo#154170
X-original-commit: 109b45f
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This PR fixes 2 issues with discuss navigation:
1. Broken backwards navigation when going back and forth from the live
chat session history.
2. Broken backwards navigation when trying to access the same thread
than the current one.
Steps to reproduce 1:
- Open the command palette
- Go to the live chat session history view
- Click on one of your channels
- History back => leads to the session history view
- History forward => leads to discuss
- History back => stays on discuss, history is broken
This occurs because the active id is not passed in the action context
when navigating backwards which leads to the URL being pushed again in
history (URL without active id is different). The active id should be
put in the context when available.
Steps to reproduce 2:
- Go to discuss
- Click on the active thread
- History back => stuck on discuss, cannot navigate backwards anymore.
We should not push in history when accessing the same thread than the
current one.
task-3422516
closesodoo/odoo#153094
X-original-commit: 029b79ad7dc28aab83289e7c3ebd4cc0dcc5d609
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this PR, the `test_complete_chatbot_flow_ui` would sometimes fail
when checking if the user can add a reaction to a message.
There are two issues:
- This step uses the `contains` helper and specify the live chat `ShadowRoot`
as the target. However, the `contains` helper uses a mutation observer
that observes the light DOM thus, changes in the shadow root are not
correctly observed.
- The target passed to the `contains` helper is the `ChatWindow` DOM
element but this element can be unmounted in-between.
This PR fixes this issue.
fixes runbot-56670
closesodoo/odoo#153382
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Since [1], the websocket worker is started when a transient thread is
added to the mail store. This occurs because this PR introduced a call
to the `addChannel` method of the bus service when the current user
was not member of the thread.
Since transient threads are not yet created, they have a partial state
that does not necessarily include channel members hence the impression
that the current user is not member of the channel.
This PR prevent starting the bus service for transient threads.
[1]: https://github.com/odoo/odoo/pull/146800closesodoo/odoo#153000
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Since #135113, calls to /im_livechat/get_session can become very
expensive on large databases with a long history of livechat sessions.
Operators who have thousands of past livechat sessions (channels) can
cause the SQL query in get_operator() to take multiple seconds.
When the livechat is set to auto-popup and there are lots of visitors,
this can become very significant.
This patch changes two aspects:
- introduce a CTE for the RTC session part, in order to avoid a
JOIN cardinality between livechat channels and channel_members - we
only care about channel membership for a RTC session
- restrict the selection of livechat channels created within the last 24h,
considering that we only care about messages sent in the last 30
minutes anyway
The second part may change the result ordering in the present of old
channels (>24h) with recent messages - but that is rather unlikely, and
an operator will be selected anyway.
This change makes a huge difference on a database with 300k livechat
channels and 1 million `discuss_channel_member` records, from several
seconds to >50ms. The results are identical or extremely similar in most
cases, and the database only needs to look at a few hundred records
instead of millions.
closesodoo/odoo#150968
Signed-off-by: Olivier Dony (odo) <odo@odoo.com>
The `test_complete_chatbot_flow_ui` ensures it is possible to add
reactions to the chat bot messages once the thread is saved on the
server.
This test was sometimes failing because the condition that is used to
wait for the thread to be persisted is incorrect: it checks that a
message with the user response exists but the chat bot question also
contains the response text.
This PR fixes the issue by using the `contains` helper instead: it
will wait until the expected state is reached.
fixes runbot-55291
closesodoo/odoo#151720
Signed-off-by: Didier Debondt (did) <did@odoo.com>
Before this PR, a race condition could occur when restarting the
chatbot: if the rpc returned before the restart message reception
on the bus, the chat would not restart. This was due to the message
being inserted twice. Since the id is used as an unique `t-key` in
the thread template, any duplicate would lead to an error.
This PR fixes the issue by checking that the message is not already
present before adding it to the thread messages.
Steps to reproduce the issue:
- Go to the contact us page
- Start a chat with the bot and proceed until the end
- Put your network in slow 3g mode
- Click on the restart button
- The chatbot is not restarting as expected
closesodoo/odoo#150975
X-original-commit: 6c535bb71edc40aaf3fa75bab702fb9be4a24779
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
The Ptt extension makes use of the `chrome.session` API to keep track
of the connected clients. Before this PR, the session storage was
initialized at the top level of the background script. This is an
issue since it will be executed after the service worker wake up thus
overwriting the existing client map. This PR removes this
closesodoo/odoo#150084
Initialization: the map will be created when needed instead.
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this PR, the "Retry loading more messages on failed load more
messages" test was sometimes failing. This test uses the `afterEvent`
helper to wait for the load message event to occur. This is too
technical and not reliable: this test just ensures that clicking on
the retry button after failing to load more messages work as expected.
This PR simplify this test and make use of the `contains` helper which
is more reliable to do so. First, 30 messages are loaded, then the
retry button appears and finally, clicking on the retry button should
load 30 more messages for a total of 60.
fixes runbot-53201
closesodoo/odoo#150012
X-original-commit: 6c1f3f0a24913484042148b7101ec6a628d5b8be
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Since [1], the `insert` method accepts the `html` option to
automatically cast record fields marked as `html` to markup. Before
this PR, this option was ignored after the first insertion if the
field value remained the same.
Steps to reproduce this issue:
- Insert a message without passing the `html` option: the body field is
an instance of string.
- Insert the same message setting the `html` option to true: the body
field of the message is still an instance of string while it should be
an instance of markup.
This PR fixes this issue.
[1]: https://github.com/odoo/odoo/pull/139501closesodoo/odoo#149953
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this PR the "Can handle im_status of unknown partner" test was
sometimes failing. This test is not related to im_status: it tests
that receiving a `mail.record/insert` notification properly inserts
the data in the store. This flow is already thoroughly tested as many
discuss functionalities rely on this mechanism. This PR removes this
test.
fixes runbot-52628
closesodoo/odoo#147705
X-original-commit: 39a368238f5fc9b8d8d4115f14a05499322e92e6
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
In [1], a context object was added to websocket requests to subscribe
to guests channels on cors live chats. However, the common mechanism
to subscribe to record channels is to pass a string channel that will
then be validated by the `_subscribe` method of `ir_websocket`. This
approach works with OdooSH out of the box while the other one does
not.
This PR removes the mechanism introduce in [1] in favor of the string
approach.
[1]: https://github.com/odoo/odoo/pull/130052closesodoo/odoo#147114
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit fixes a non-deterministic error in the bus module. Testing
the bus service is difficult because it relies heavily on async code.
Until now, `nextTick` was used but there is no guarantee that this is
enough. This commit introduces the `waitForChannels` method that
awaits the channel subscriptions to be done before resolving.
fixes runbot-21942,54467
closesodoo/odoo#147616
X-original-commit: 429a0668a4bed52eff1c7b8cd0c5c66261678699
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Several tests are non deterministic because they are using
`assert.verifySteps` at the wrong moment. Helpers such as
`afterNextRender`, `nextTick`, `Deferred` are used but those are
either not reliable or cumbersome to setup.
This PR introduces an asynchronous API on top of
`assert.step`/`assert.verifyStep`. This will wait until steps are
executed or until the timeout is reached.
fixes runbot-52660,54471,52794
closesodoo/odoo#147455
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
The `calendar notification` tests patch the `setTimeout` function.
This sometimes leads to infinite recursion when the `multi_tab`
service has enough time to initialize: this service make use of
`setTimeout` to call the `heartbeat` method repeatedly. Moreover,
patching the `setTimeout` method is not a good idea since it makes
this method synchronous which totally changes the flow that is tested.
This PR fixes this issue by using the `contains` helper instead: this
method will wait for the element to be inserted in the DOM and perform
the assertion afterwards.
closesodoo/odoo#147503
X-original-commit: 973db5a
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
The "Channel subscription is renewed when channel is left" test
ensures the bus subscription is renewed when the user leaves the
channel. In order to do so, the test relies on a patch of the bus
service and awaits the `waitUntilSubscribe` helper. This is not
correct: the subscription will never be triggered since the bus
service method is patched to only call `assert.step`.
This test passes most of the time by luck: `waitUntilSubscribe`
detects the first subscription (the one that is triggered when
starting the bus service) and the delay is most of the time enough for
the step to be ready.
This PR fixes the issue by:
- waiting the first subscription to ensure it does not interfere with
the test.
- removing the bus service patch: waiting for the subscription is
enough.
fixes runbot-46941
closesodoo/odoo#147255
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this PR, the "can reconnect after late close event" test
was relying on the `nextTick` helper to check which bus events
were received when the device switches from online to offline.
This test was non deterministic since a tick might not be enough
to receive the related events: the bus service communicates with
a shared worker through the MessagePort API, the worker uses a
Websocket which dispatch events upon connection/reconnection.
This commit replaces the use of the `nextTick` helper by the
dedicated `waitForBusEvent` helper which resolves once the event
is received.
fixed runbot-45695
closesodoo/odoo#147068
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Since [1], the test that ensures live chat threads are sorted
according to their last interrest date is broken. Indeed, the sort was
moved from `im_livechat` to `website_livechat`. This is incorrect.
Also, most of the compare functions used to sort by datetime were
incorrect: those datetimes can be undefined in which case the result
of the compare function would be `NaN`.
This PR moves back the sort function in the correct module and
introduce a standard way to compare by datetime which handles
undefined datetimes correctly.
[1]: https://github.com/odoo/odoo/pull/143382
fixes runbot-47784
closesodoo/odoo#146805
Related: odoo/enterprise#53065
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This PR fixes a test that ensures the bus subscriptions are updated
when a member is invited to a channel. This test waits some time
before checking if the subscription is done. Sometimes, a tick is not
enough and the test fails. This PR adds a deferred that resolves when
the subscription is done that can be awaited to ensure the timing is
always right.
fixes runbot-46941
closesodoo/odoo#146848
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
When a live chat is created on the server, the `/mail/thread/messages`
route is called. This is not required since we know for a fact the
thread was just created. This PR prevent this useless request.
task-3646201
closesodoo/odoo#146785
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Since [1], messages received out of focus are notified to the user via
the tab title. In order to do so, the title service is used. This
service changes the tab title according to its internal state.
When the live chat is embed on a page, the original title of the page
is not coming from the title service. When the service state changes,
the title is replaced without taking into account the original title.
This behavior is not correct.
In practice, this functionality is only used by the `web` bundle. The
error occurs because the code handling this behavior is placed in the
common bundle while it should not. This PR fixes this issue by moving
this code to the `web` bundle.
task-3644431
[1]: https://github.com/odoo/odoo/pull/145216closesodoo/odoo#146752
X-original-commit: 43b67c377b6a236cb009b21afd62d8c593ef9cd6
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
When a page is reloaded with the chat bot, it sometimes restarts from
the beginning. This commit ensures the chatbot starts where it left
after a page reload.
closesodoo/odoo#146175
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Since 16.0, the number of unread messages is not shown anymore on the
tab title. This is due to the `set_title_part` event being sent on the
wrong bus. The title service is the new preferred way to change the
document title. This PR makes use of this service to restore the
previous behavior.
closesodoo/odoo#145329
X-original-commit: 5c4c5d2076d9dd4b767b01a88a0ab95127bb4f6b
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
*: im_livechat.
Since 17.0, the new message separator is displayed for guests. The
`set_last_seen_message` rpc is also triggered in order to save this
information on the server side. However, the `_channel_seen` method
does not handle guests as it should.
As a consequence, the new message separator is always displayed and
the rpc call is always done when a guest loads the public page.
This PR enable guest support for this feature. Not that for live chat
channels, visitors cannot access the operators seen infos.
task-3603603
closesodoo/odoo#142546
Related: odoo/enterprise#52118
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
In order to be published on the chrome extension store, an extension
must provide at least one screenshot and a 128x128 icon.
Until now, the extension assets only contained a 100x100 icon that was
used as 128 and did not contain any screenshot.
In order to ease updates on the chrome extension store, this commit
updates the two icons used by this extension to match the expected
dimensions and adds the required screenshot.
At the same time, this commit updates the extension readme to warn
about ChromeOS limitations (ChromeOS does not support global
commands).
follow-up of task-3612720
closesodoo/odoo#144828
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this commit, rtc join/leave sounds were played on every
tab. This can be due to two issues:
- notifications related to the current user should not play sound
since it is already played by the tab that triggered the action.
- only the main tab should play the sound.
This commit implements this behavior.
Steps to reproduce the issue:
- Open two tabs
- Start a call on the general channel
- Notice that the "join" sound was played twice
- Leave the call
- The same applies for the "leave" sound
task-3355352
closesodoo/odoo#144436
X-original-commit: dfbd95f
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
`psycopg2` errors sometimes happen during tests. This is caused by
race conditions between several `cr.execute()`/`cr.fetch*`.
This is even worse with websockets that are long lived connections
that sometimes open a cursor in the middle of the test.
Before websockets, longpolling was just disabled during tests. This
commits disable websockets as well in order to prevent those errors
as much as possible.
Some live chat tours were updated in [1] after the websockets intro-
duction due to some race conditions. This was reverted as the fix
relied on a hack on websockets that are now unavailable.
fixes runbot-25357,24809
[1]: https://github.com/odoo/odoo/pull/103521closesodoo/odoo#143647
X-original-commit: e3b07a301036fcce76ebbbd856b507326b88160a
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
The bus service communicates with the websocket worker in
order to deliver messages coming from the bus. Most of the
time, it is using a `SharedWorker` but when this kind of
worker is not available, it fallbacks on a `Worker`.
During tests, the `SharedWorker` is mocked to prevent opening
websockets on the server. However, the `Worker` is not.
Since [1], opening websockets during tests is forbidden thus,
any test relying on `Worker` and expecting a connection to be
established would fail.
This PR solves this issue by mocking the `Worker` constructor
as well.
[1]: https://github.com/odoo/odoo/pull/141519closesodoo/odoo#143988
X-original-commit: 1c67542decb1b6ad38fd15532cb6ac82417ca6dc
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Currently, a chat window is folded when hidden and the server is
notified. This is incorrect and leads to useless rpc calls/undesirable
fold state. A chat window is only hidden when space is lacking to display
them all. Only a user interaction should be able to fold a chat window.
Since folding the chat window when hidden is an implementation detail
only used to show the chat window header in the hidden windows dropdown,
this PR removes this behavior and adapt the hidden windows menu to
achieve the same result.
Steps to reproduce the issue:
- Go to Odoo, resize your browser so that it can only fit 2 chat windows.
- Open two chat windows, server is notified twice: so far so good.
- Open another chat window: server is notified twice: this is not correct,
the server should only be notified of the newly opened chat window.
- Reload the page: the server is notified once for each window not fitting
in the screen, this is incorrect as well.
task-3600480
closesodoo/odoo#143438
X-original-commit: 27f09bfc5049b1350b7e940a7beef92f63799771
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Currently, discuss push-to-talk only works when the browser has focus
because key events are not fired otherwise.
This commit adds an extension for chromium-based browsers that allows
to register a system-wide push-to-talk shortcut and adapts the rtc
service in order to listen to the extension events.
closesodoo/odoo#140752
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this commit, the "add reaction" button was available even when
the thread is not persisted. This is wrong since those messages are only
temporary thus not known by the server: a crash would occur when trying
to add a reaction to such messages.
This commit disables reactions for temporary messages.
Steps to reproduce the issue:
- Go to the `/contactus` page
- Open a chat with the welcome bot
- Try to add a reaction to its first message
- An error modal appears
task-3603577
closesodoo/odoo#142718
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Odoo periodically updates the user online status. This is
done every minute and is throttled in order to ensure it won't
be triggered more than it should.
Since [1], the underscore `throttle` function has been replaced
by the `throttleForAnimation` function. This is not equivalent:
the function won't be triggered if there is no animation which
result in an outdated user status.
This issue was highlighted by the live chat: the button does
not show up when there is no available operator.
Steps to reproduce the issue:
- Log in on Odoo with live chat installed
- Go to a web page that uses the live chat widget
- Wait more that one minute and refresh the page
- The live chat button is not shown anymore: the only
operator is considered as disconnected.
This PR fixes that issue by re-introducing the underscore
throttle function: it is robust and can be needed, not all
throttles are linked to animations.
[1]: https://github.com/odoo/odoo/pull/120437.
opw-3578517
closesodoo/odoo#142160
X-original-commit: f64a7cbad3dee3ffc365b931306b1c13c8bff536
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this PR, the dropzone background was not showing on
the embed live chat. The dropzone is displayed as a `main
component`. In the Odoo frontend, the main component container
is displayed outside of the live chat shadow dom, where the
`bg-view` class is not available. This commit replaces this
class by the `bg-100` one that is almost the same and available
in the frontend.
task-3595537
closesodoo/odoo#142055
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the templates of the embed live chat were
not translated. This is due to the live chat embed app being
mounted without giving any `translateFn`.
This commit fixes this issue.
opw-3509309
closesodoo/odoo#141869
X-original-commit: 27aa2cb0ad1d279f72838000932d94e91cb436f3
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
When the bus service is loaded, it connects to the websocket
worker and passes some information that are used to determine
whether the websocket connection is outdated.
Amongst them, the user id is used to detect when the user changed
and when the websocket connection should be refreshed.
This is not enough to ensure the websocket connection is still
relevant: the user id could be the same but the db could have
changed. The websocket would then be linked to the previous
database.
This commit fixes the issue by sending the db name alongside the
user id. This will ensure the connection is refreshed when it is
outdated.
Steps to reproduce the issue:
- Log in on db1 on 2 tabs
- Log out
- Log in on db2
- Try to star a message in the discuss app
- Nothing happens, the messages are sent from db2 but the socket
listens to db1
closesodoo/odoo#141263
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
The `onWillStart` hook that was used in the thread component but was
replaced by the `onMounted` hook. Indeed, fetching the messages in
the `onWillStart` hook was leading to an infinite loop (props updated
as a side-effect of the `onWillStart` hook).
After messages are loaded, the scroll position of the thread is
restored. Since this is done after the component is mounted, another
render is triggered and results in a flicker when opening the thread.
This commit fixes this issue by waiting for the thread to be mounted
and for the scroll position to be restored before showing the message
list.
closesodoo/odoo#141145
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Discuss models use relationnal fields. Since [1], the implementation
of the `unshift` method changed for `many` fields. The new
implementation is incorrect: unshifting several records results in an
insertion on the inverse order which differs from the native
implementation.
This issue broke the loading of older messages in discuss: older
messages are inserted with the `unshift` method thus in the inverse
order.
[1]: https://github.com/odoo/odoo/pull/136539closesodoo/odoo#140747
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
The live chat relies on `session.origin` to send its requests to
the server when its embed in an external page. `web.base.url` is
only set when a user authenticates and is wrong when no user
connected yet. Since `session.origin` uses the value of `web.base.url`,
a crash occurs when opening the website with live chat enabled on a
fresh instance of odoo. This commit removes the use of `session.origin`
in the frontend code since it is useless anyway. The `url` function
is used to format URLs since it either happens `session.origin` if
available or `location.origin` otherwise.
Steps to reproduce:
- Create a new odoo database with website_livechat installed
- Go to the log in page
- A crash occurs
closesodoo/odoo#140156
X-original-commit: 62e266e
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this commit, messages in livechat from visitor POV show
2 emoji icons in the quick actions. This is confusing and comes
from 2 actions sharing this exact same icon: "Add a reaction"
and "View reactions".
This commit fixes the issue by reducing the number of quick message
actions to 2 for the embed live chat. In other contexts there's
"Reply-to" and "Mark as Favorite" in quick actions, so the
"View reactions" item is always in expand menu.
Note that this "dirty" fix come from 2 actions with same icon.
Eventually we should fix that by clearly making icons unique.
This solution is decent for the time being, giving us more time
to make a dedicate icon for one of the emoji actions.
task-3498446
closesodoo/odoo#140335
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Since [1], highlighting a pinned message from the notification sent
to the channel does not work anymore. This is due to a `super` call
missing. This PR fixes the issue.
Steps to reproduce:
- Go to a channel
- Pin a message
- Click on the "message" link
- Nothing happens
[1]: https://github.com/odoo/odoo/pull/121418closesodoo/odoo#139948
X-original-commit: 68992ba05eb48459800df17707741295a4f47c9c
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Since [1], guest is added to the channel immediately instead of
waiting for the guest name to be set. Since the guest is not in
the context when posting je "join" message, the author of the
message is the public user instead of the guest. This results in
an incorrect message ("public user joined the channel") since the
frontend relies on the author to set the name. This commit fixes
the issue by adding the guest to the context.
Steps to reproduce:
- Go to a channel
- Copy the invitation link
- Join the channel with this link
- The message is incorrect
[1]: https://github.com/odoo/odoo/pull/138330closesodoo/odoo#139892
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this commit, the `visitor_leave_session` route was called
when a user logged in: the session of the visitor is outdated and
will never be activated again. This causes an error with portal
users since channel members are not based on the guest but on the
current user when available. This commit fixes the issue by not
calling the route: the session will be garbage collected as all
the others.
Steps to reproduce the issue:
- Go to website livechat (public user)
- Start a chat and send a message
- Log in as portal user
- An error occurs
closesodoo/odoo#139631
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this commit, live chat would fail for guest portal. In this
scenario, there is no guest token. Before this commit, the guest
token was sent anyway with `null` as value which caused a crash.
closesodoo/odoo#139585
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this commit, an error occured when opening the discuss public
page as a non internal user. This is caused by a read rpc being done
while the user is not allowed to do it. This commit ensures this rpc
is only done when allowed.
Steps to reproduce the issue:
- Open Odoo with Mitchell Admin
- Go to a public channel
- Start a RTC call
- Join the channel as guest with the invitation link
- A pop up appears
closesodoo/odoo#139397
X-original-commit: c7e66f3878b451001dbe4e8e3cdd8ced9a8ed632
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit reduces the size and avoid conflicts caused by
the embed live chat bundle: jquery, legacy libs...
At the same time, this commit fixes the emoji picker that was
wrongly positionned and scrolled up the page when opening.
Finally, this commit ensures the chat window is always at the
bottom of the screen.
opw-3539362
closesodoo/odoo#139261
X-original-commit: 1b29419e50343bfd723b41368ba38ce63b063d92
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit fixes the `website_livechat_chatbot_flow_tour` that was
failing in a nondeterministc way. This is due to the tour sometimes
taking more than `60` seconds which is the default timeout for python
tours.
Most of the time is consumed waiting for the user to finish its
multiline input. This issue is solved by shortening the delay to
consider the multiline input as done: from `10`s to `500`ms.
fixes runbot-24557
closesodoo/odoo#139034
X-original-commit: 7788f2f1879dda2381a7d2e93e8a0472f4621d14
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Since [1], the notification option for the live chat button does not
work. This commit restores it.
[1]: odoo#122834
task-3555864
closesodoo/odoo#138904
X-original-commit: 2f8683d22a781fce6cc5c1c39b0018f1b531fa8a
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
[1] tried to remove nondeterminism from bus tests. However, several
issues remain:
- the asset watchdog bundle is added to the registry during bus tests.
Websocket tests wait for the `connect` event after starting the environment.
This `connect` event can be triggered sooner than expected since the asset
watchdog services starts the bus.
- a the random delay is added to the reconnection attempts.
- `nextTick` is kept when waiting for a client to leave the worker.
This commit fixes those issues.
[1]: https://github.com/odoo/odoo/pull/138221closesodoo/odoo#138639
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Live chat bundle structure changed in [1]. This PR misplaced a scss
file which results in a class missing from the Odoo backend. This
PR solves this issue
[1]: https://github.com/odoo/odoo/pull/138536closesodoo/odoo#138830
Signed-off-by: Didier Debondt (did) <did@odoo.com>
Since [1], the live chat button is displayed after a conversation ended.
This change introduced a bug with with the chat bot.
Steps to reproduce:
- Open a chat with the bot
- Reload the page
- Close the live chat
- Open another chat
- The bot does not start
[1]: https://github.com/odoo/odoo/pull/134513closesodoo/odoo#138826
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This PR fixes two issues:
- Incorrect write on `channel_member_ids` (trying to link guest instead
of channel member)
- Incorrect condition in `livechatService.leaveSession` that relies on
the live chat to be initialized while it can acutally be called before
if the current session is outdated.
This could result in server errors in the following scenario:
- Open a live chat
- Log in
- Open a live chat from the website app
- Log out
- Reload the page
closesodoo/odoo#137834
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This PR fixes two issues:
- Incorrect write on `channel_member_ids` (trying to link guest instead
of channel member)
- Incorrect condition in `livechatService.leaveSession` that relies on
the live chat to be initialized while it can acutally be called before
if the current session is outdated.
This could result in server errors in the following scenario:
- Open a live chat
- Log in
- Open a live chat from the website app
- Log out
- Reload the page
Part-of: odoo/odoo#137834
This commit improves the live chat bundles:
- `core`
- `common`: hold files that are common to every feature
- `web`
- `standalone`: hold files for the embed live chat and is splitted
in 4 sub-bundles:
- `common`
- `frontend`: should only be added in the Odoo frontend.
- `external`: should only be added outside of Odoo
environment (e.g. support page).
- `cors`: should only be added when the live chat
is requested from a different origin.
This will make live chat folder structure closer than the one used
in mail and avoid code duplication.
task-3537697
closesodoo/odoo#138536
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this commit, websocket tests were sometimes failing with the
`no result to fetch` error. This is due to a race between the
`subscribe` event being received which itself leads to dispatching bus
notifications interferring with the rest of the test (the connection
is shared).
In order to solve this issue, the `WebsocketCase` now exposes a
`subscribe` method that waits for this dispatching to be done in order
to ensure it will not interfere with the rest of the test.
Some tests were also failing because the subscription was done with 0
as the last notification id. This is an issue since this could lead to
notifications being sent while they are not expected.
In order to solve this issue, `last_notification_id` is now correctly
passed when subscribing to channel notifications.
fixes runbot-24226
closesodoo/odoo#138649
X-original-commit: 3256885fd08d33a67d7165fa33d373fd039ef7af
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit fixes the `website_livechat_chatbot_flow_tour` that was
failing in a nondeterministc way. This is due to the tour sometimes
taking more than `60` seconds which is the default timeout for python
tours.
Most of the time is consumed waiting for the user to finish its
multiline input. This issue is solved by shortening the delay to
consider the multiline input as done: from `10`s to `500`ms.
fixes runbot-24557
closesodoo/odoo#138629
X-original-commit: cdca70941dab1b20dca9bdf9d44d354327176b59
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this commit, the `_message_format` override of the live chat
module would overwrite the author. Since [1], values provided by the
live chat override are incomplete which result in incorrect message
display in the discuss app. This commit modify the live chat override
to enrich the author instead of totally overwriting it.
Steps to reproduce:
- Log in with mitchell admin
- Change its live chat user name in its profile
- Open a chat with a visitor
- Send a message with mitchell
- The message is incorrectly marked as sent by the visitor
[1]: https://github.com/odoo/odoo/pull/137276closesodoo/odoo#138533
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit makes bus tests more robust by implementing
functions that wait for some events instead of relying
on `nextTick` that might or not be sufficient.
fixes runbot-23097
closesodoo/odoo#138221
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit cleans the bus tests by:
- flattening the tests structure by putting tests outside
of the `QUnit.module` function.
- removing unnecessary `assert.expect` calls.
- adding an helper to add common bus service to the registry
Part-of: odoo/odoo#138221
Before this commit, diagnosing websocket handshake error was
cumbersome since the only information available was the return
code of the initial HTTP request (400).
The HTTP stack does not log `werkzeug.exceptions.HTTPException`
and derivated classes since they are valid responses. This commit
adds a log in order to provide more insight about what went wrong.
closesodoo/odoo#138083
X-original-commit: 50af40302c2849b99e8e501bc170cf887ca8e6fa
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Since [1], live chat visitors are using the mail guest system for
authentication. With this change, visitors are allowed to reach the
attachment upload routes (even if nothing allows it in the frontend
for now). This commit restricts attachment upload for guest and portal
users with the `allow_visitor_upload` field that can be toggled.
At the same time, this commit enables file upload when authorized
on the frontend and for cross origin live chats.
[1]: odoo#129770
task-3332628
closesodoo/odoo#137574
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this PR, if an error occurred when leaving the session,
the state of the livechat was not properly reset. This is an
issue since this could lead to a visitor being stuck with an
outdated session. This commit ensures the session state is reset
even if an error occurs during the session leave rpc.
This PR also fixes an issue where two `init_messaging` rpc were
sent when restoring a live chat session.
closesodoo/odoo#137518
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This PR makes several actions available for the embed livechat
such as:
- calls
- message edition
- message reactions
- link previews
task-3523930
closesodoo/odoo#136618
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This PR changes the operator allocation algorithm so that operators
in a call with already two ongoing chats are not prioritized over
more occupied operators that are not in a call.
part of task-2900771
closesodoo/odoo#135113
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit adds the `ui.scss` file in order to provide image
related css classes to the embed livechat (`o_object_fit_cover`)
was missing.
Steps to reproduce:
- Go to the website
- Open a livechat
- Paste a link in order to display a link preview
- The image is stretched since the `o_object_fit_cover`
class is not available in the shadow DOM.
closesodoo/odoo#136656
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
The livechat service thread getter relies on the thread type to find
the current livechat thread. Since guest could have many channels it
is incomplete, the id should also be checked. This PR fixes this issue.
closesodoo/odoo#135378
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This PR removes the livechat's discuss route overrides
that added `cors="*"` since they are not safe (different databases on our
cloud are considered as SameSite).
In the meantime, embed livechats won't work as expected since cors is
prevented and will be fixed in a following PR.
closesodoo/odoo#135260
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this commit, executing the `/history` command in a livechat
would do nothing. Indeed, the message was sent on the wrong target
through the bus so the history request was never received by the
visitor client. This commit fixes the issue by sending the notification
on the channel instead of the channel uuid.
closesodoo/odoo#135254
Signed-off-by: Didier Debondt (did) <did@odoo.com>
This commit prevent the livechat visitor from executing actions
on frontend messages (that are not known by the server).
Steps to reproduce the issue:
- Open a livechat with an operator
- A welcome message is displayed ("How can I help you?")
- Add a reaction to this message
- A crash occurs
closesodoo/odoo#134987
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the push to talk key combination was wrongly
detected. Indeed, it was dependent on which key was pressed first.
Steps to reproduce:
- Register "ctrl + alt" as the push to talk key
- Press control then alt, push to talk does not work
- Press alt then control, push to talk works
- If you unpress the alt key, the push to talk will stop as expected
- If you unpress the control key, the push to talk will keep going
This commit fixes the issue.
closesodoo/odoo#134981
X-original-commit: 3e4ed2a43ad23116c095af67cb7e5736a9854820
Signed-off-by: Thanh Son Dodeur (tso) <tso@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit adds the discuss message features to the livechat
threads:
- Edition/deletion of messages
- Reactions
- Replies
It also improves the history view present in the channel form view
by showing replies.
task-2742676
closesodoo/odoo#133456
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit fixes the "website_livechat_chatbot_flow_tour" which was
nondeterministic. This was due to the message service update which was
assigning data blindly based on the payload instead of handling it
properly. This is solved by enriching the chatbot step instead of
overwriting it.
runbot-24625
closesodoo/odoo#134778
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the livechat was still using a dedicated
route to fetch messages on page load. Since [1], visitors are
actually mail guest so they can access the classic mail route
in order to do so. This commit adapt the livechat code to use
this route instead of the custom one.
At the same time, this commit simplify the livechat service.
part of task-3332628
[1]: https://github.com/odoo/odoo/pull/129770closesodoo/odoo#133430
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the livechat button was not shown anymore after
closing the chat window. Since the livechat button is always present
from now on, the button is now draggable.
task-3358161
closesodoo/odoo#134513
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, calling `record.delete` twice would
result in a crash. This is due to `this.Model`being cleared
once the delete is done. This commit skips the deletion if
it was already done: calling delete will result in the desired
state anyway.
This can be easily reproduced:
- Throttle your network
- Send a message on the discuss app
- A crash occurs
closesodoo/odoo#134254
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the "subscribe to single notification"
test failed in an nondeterministic fashion. This commit
solves this issue.
fixes runbot-24033
closesodoo/odoo#134243
Signed-off-by: Didier Debondt (did) <did@odoo.com>
This PR fixes a server error when trying to test a chatbot that
appeared with the [livechat refactoring].
Steps to reproduce:
- Go to a livechat channel form view
- Click on the "chatbot" smart button
- Click on a chatbot
- Click on the "test" button
- An internal server error occurs
task-3485014
[livechat refactoring]: https://github.com/odoo/odoo/pull/122834closesodoo/odoo#134227
X-original-commit: dfc50ea4e4fb327876458afee1b807e36ce80c2b
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, message edition was available when
pressing the arrow up key. This was a mistake since the
message edition route is not available yet for livechat
visitors. This PR fixes this issue.
closesodoo/odoo#133815
X-original-commit: ab7e70e809b3c7fa5044139582bd09a9e94ee377
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit improves the mail `onChange` method by adding
the support for multiple keys. This will make the code shorter
and easier to read.
closesodoo/odoo#133778
Signed-off-by: Didier Debondt (did) <did@odoo.com>
This PR adds a panel to consult all attachments of a discuss channel
easily.
task-3476444
closesodoo/odoo#132784
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>