Commit Graph
85 Commits
Author SHA1 Message Date
Sébastien Theys 694d501a35 [REF] mail, im_livechat: move /mail/chat_post to im_livechat
It is only used there.

In preparation of splitting discuss and mail modules.

Part of task-3265211

closes odoo/odoo#119306

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-04-24 18:25:59 +02:00
Sébastien Theys bcce4be8e9 [REF] mail, im_livechat: move /mail/chat_history to im_livechat
It is only used there.

In preparation of splitting discuss and mail modules.

Part of task-3265211

closes odoo/odoo#119302

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-04-22 05:51:59 +02:00
Sébastien Theys 90cb44e1e1 [REF] mail, *: rename mail.channel to discuss.channel
* = bus, calendar, crm_livechat, hr, hr_holidays, im_livechat, mail_bot,
    mass_mailing, privacy_lookup, test_discuss_full, test_mail,
    test_mail_full, website_crm_livechat, website_livechat, base

In preparation of splitting discuss and mail modules.

Part of task-3265211

closes odoo/odoo#118354

Related: odoo/upgrade#4553
Related: odoo/enterprise#39661
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-04-21 02:21:53 +02:00
Julien Castiaux 3d1f486bcc [IMP] *: update modules to use the new geoip API
request.geoip is no more a dictionnary cached in the session. It is now
a full blown object with lazy and smart geolocalisation capabilities.

Among other things, the previous dictionnary API is now deprecated. The
changes are:

* `request.geoip['country_name']` -> `request.geoip.country_name`
* `request.geoip['country_code']` -> `request.geoip.country_code`
* `request.geoip['city']` -> `request.geoip.city.name`
* `request.geoip['latitude']` -> `request.geoip.location.latitude`
* `request.geoip['longitude']` -> `request.geoip.location.longitude`
* `request.geoip['region']` -> `(request.geoip.subdivisions[0].iso_code if request.geoip.subdivisions else None)`
* `request.geoip['time_zone']` -> `request.geoip.location.time_zone`

It is safe to access all the attributes. Doing `request.geoip.city.name`
when the geolocalization failed (missing db, invalid address, ...)
evaluates to None. It does not raise an AttributeError.

Task: 2848206
Part-of: odoo/odoo#91337
2023-01-03 13:16:02 +01:00
tsm-odoo 131948aca5 [FIX] im_livechat, *: fix channel created before user interaction
*: website_livechat.

Before this PR, a `mail.channel` record would have been created before
any user interaction. Since the introduction of the welcome bot, this
issue has gotten worse. Indeed, any user accessing a page with the bot
enabled created a useless channel.

Before 15.3, around 15k channels were created each month, after 15.3,
300-500k channels are created each month, most of them empty channels
whom creation could have been avoided.

This PR fixes the issue by waiting the first user interaction before
creating the channel.

closes odoo/odoo#108566

X-original-commit: b2eaf32ba92e537c7eefba6489533613be1b8c91
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-12-28 10:41:05 +01:00
Alexandre Kühn 36346eb1d0 [IMP] im_livechat, *: Show Livechat Button with notification
*: mail, website_livechat

This commit adds new option in Livechat Button visibility
"Show with notifcation", which allow to see livechat button
and also display a customizable floating text next to button.

This text appears 1 second after the livechat button become visible.

Task-2937993

closes odoo/odoo#102930

X-original-commit: 785356f46b49d1b3d9b975319c87f39266694b82
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
2022-10-10 18:08:48 +02:00
Sébastien Theys cb8583c16e [FIX] im_livechat: prevent crash with avatar of invalid operator
closes odoo/odoo#101948

X-original-commit: f6a01f9d69bd2115ad7e7c0dbb3ffb041fc9e67e
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
2022-10-03 16:19:08 +02:00
Sébastien Theys 545d23888b [IMP] mail, im_livechat, *: add typing for guest and clean code
* = bus, hr_holidays, test_discuss_full

- use channel member instead of partner for typing
- use channel member instead of partner for all other return values from server
- remove temporary partner hack in livechat and keep public partner
- remove some obsolete convert data
- adapt format methods accordingly

task-2664853

closes odoo/odoo#98923

Related: odoo/enterprise#30760
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-09-01 20:21:58 +02:00
Alexandre Kühn b7b4161873 [IMP] im_livechat, *: Refactor JS Public Livechat (step 13)
*: website_livechat

This commit is a step towards refactoring the JS of public livechat,
so that it reuses the same architecture as the code of Discuss.
This implies code that uses JS models and OWL components.

Task-2943607

closes odoo/odoo#97403

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-08-03 19:33:53 +02:00
Alexandre Kühn ac39fe6768 [MOV] im_livechat, *: Refactor JS Public Livechat (step 8)
*: website_livechat

This commit is a step towards refactoring the JS of public livechat,
so that it reuses the same architecture as the code of Discuss.
This implies code that uses JS models and OWL components.

Task-2925850

closes odoo/odoo#96447

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-07-21 01:53:32 +02:00
Louis Wicket (wil) fdcaa53ca0 [IMP] mail, *: rename mail.channel.partner to mail.channel.member
* = calendar, crm_livechat, hr_holidays, im_livechat, privacy_lookup,
privacy_lookup, test_discuss_full, test_mail_full, website_livechat

closes odoo/odoo#95912

Related: odoo/upgrade#3681
Related: odoo/enterprise#29433
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-19 11:50:37 +02:00
Alexandre Kühn 5206b66aed [MOV] im_livechat, *: Refactor JS Public Livechat (step 6)
*: website_livechat

This commit is a step towards refactoring the JS of public livechat,
so that it reuses the same architecture as the code of Discuss.
This implies code that uses JS models and OWL components.

Task-2896237

closes odoo/odoo#94722

Related: odoo/enterprise#28913
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-06-28 00:36:42 +02:00
Alexandre Kühn 190feb8d6d [IMP] im_livechat, *: make JS models available in livechat external lib
This commit make messaging service available in the frontend and in
the livechat external lib bundle.

This is preparation to refactoring JS livechat to use models and OWL.

*: bus, mail, survey, web, website_livechat

Task-2870899

closes odoo/odoo#92786

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-06-13 16:51:27 +02:00
Nemael 48fd3538fe [IMP] im_livechat, *: split public livechat templates per widget
*: website_livechat

The goal is to split the public_livechat.xml file into multiple parts,
and move each template into its own file located in
`im_livechat/static/src/legacy/widgets/`

Task-2825235

closes odoo/odoo#92671

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-06-02 12:05:16 +02:00
Julien Castiaux da8def8e41 [IMP] core, web: Delegate delivery of static files
Rationnals
----------

Web servers can serve some resources (e.g. static files) right away
without any interaction with the web application. The network model of
most web servers makes them capable of handling thousands of
simultaneous requests when it comes to intensive IO operations such as
streaming data from a file. The network model of Odoo is different: it
is capable of a lot of processing power but can only serve a handful of
requests at a time, i.e. Odoo (with some help from postgres) is
optimized for CPU operations, not IO.

Some users don't configure their web server, they use a basic
configuration that relay all requests to Odoo. The result is that many
Odoo HTTP Workers can be busy streaming static files instead of
processing other requests. This can lead to a worker starvation, i.e.
all workers are busy streaming files and cannot process new requests.

X-Sendfile
----------

In this work, we add the support for the [X-Sendfile] header family,
they are multiples http headers that can be used by the web application
to communicate with the web server in order to delegate the delivery of
files stored on the file system. Odoo still receives the request but it
does no more stream the file content from within its HTTP worker,
instead it skips the response body altogether and sets the `X-Sendfile`
special header with the path of the file on the filesystem. The web
server intercepts that special header, open the file and stream it.

Using those headers, we can use the best of both the web application and
the web server. The web application is still responsible to locate the
resource and verify the access rights, the web server is still
responsible of streaming the content.

Using X-Sendfile is opt-in via the `--x-sendfile` CLI flag. We set both
`X-Sendfile` (apache) and `X-Accel-Redirect` (nginx). If you are using
apache, make sure `mod_xsendfile` is enabled. If you are using NGINX
you have to add the following location block:

    location /web/filestore {  # custom path, hardcoded within Odoo
        # Prevent access from the outside world, i.e. makes this
        # route only accessible via X-Accel. MANDATORY!!!
        internal;

        # Give access to the filestore using this server's
        # permissions. Odoo is in charge of verifying the access
        # rights.
        alias /path/to/odoo/data-dir/filestore;
    }

The Odoo [deployment documentation] has been updated accordingly.

[X-Sendfile]: https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/
[deployment documentation]: https://www.odoo.com/documentation/master/administration/install/deploy.html#serving-static-files-and-attachments

Changes to the API
------------------

To benefit most from X-Sendfile, all APIs related to streaming content
over HTTP has to be adapted. They are: (1) `request._serve_static`,
(2) `ir.http._serve_fallback`, (3) `/web/content` and (4) `/web/image`.

Each used it own way to deliver content: (1) `_serve_static` was using
`send_file` (flask's send_file that as been vendored with odoo 10
years ago and not maintenained since then), (2) _serve_fallback was
handcrafting a `werkzeug.wrappers.Response`, (3) /web/content-image were
using the "binary server" `ir.http.binary_content` API.

I has been decided to remove all 3 APIs and to merge the code inside of
the new `http.Stream` object and the `ir.binary` helper model.

A Stream wraps what is going to be sent to the browser, it can be a path
to a file on the locale filesystem, a blob of raw data or an URL to an
external resource. The Stream also holds various metadata that are
mainly used for caching. The preferred way to create a Stream is via one
of its three factories so that all the metadata are set. The factories
are: `from_path`, `from_attachment` and `from_binary_field`. A stream
instance exposes a single method `get_response()` used to create the
corresponding HTTP response object out of the stream.

Inside of `ir.http` were a few methods that were not related to the http
routing and formed what was called the "binary server". All those
methods have been removed and the feature have been refactored inside of
the new `ir.binary` model. The removed methods are:

- `_xmlid_to_obj`
- `_get_record_and_check`
- `_binary_ir_attachment_redirect_content`
- `_binary_record_content`
- `_binary_set_headers`
- `binary_content`
- `_response_by_status`
- `_get_content_common`
- `_content_image`
- `_content_image_get_response`
- `_placeholder_image_get_response`

The new `ir.binary` abstract model exposes the following utilities:

**`_find_record`**

Find an attachment or a record with a binary-field out of an xmlid or
out of a pair record-model/record-id. Check the access rights and the
access token.

**`_get_stream_from`**

Create a Stream from an attachment or a record with a binary-field.

**`_get_image_stream_from`**

Same as `_get_stream_from` but adapted for images. It sets a sensible
ETag on the stream and has image resizing support.

**`_placeholder`**

Get the image placeholder blob.

Testing
-------

It is possible to test the web server configuration using the
`test_http` module. Install the module then run the unittest using the
`webserver` test-tag. By default it attempts to connect to a web-server
running on `http://localhost:80`, you can change this URL by setting the
`WEB_SERVER_URL` environment variable.

    odoo-bin -i test_http --stop-after-init
    WEB_SERVER_URL='http://localhost:80' odoo-bin --test-tags webserver --stop-after-init

closes odoo/odoo#88134

Task: 2801675
Related: odoo/documentation#2083
Related: odoo/enterprise#26191
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-06-01 02:53:59 +02:00
Aurélien Warnon d7c6a5a3ca [IMP] [im|website]_livechat: make operators avatars publicly available
This commit improves the livechat to always allow website visitors to be able
to see the operator avatar, regardless of ACLs.

Indeed, we currently depend on ACLs and when website is installed, the
visibility of the operator avatar depends on his website_published status.
Which does not make much sense as it requires extra configuration to make it
work.

Instead, we now consider that all livechat operators and all chatbot operators
have their avatar publicly available, using a custom livechat route.

Task-2813529

closes odoo/odoo#89756

X-original-commit: 127bf62a5d701f8d2f1d4b246f55cc8ca8630dcf
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-04-27 07:52:18 +02:00
Julien Castiaux c46f4b908a [IMP] *: request.session.geoip -> request.geoip
Commit "[IMP] core: don't save visitor default session" moved the geoip
from the session to the request with a deprecation warning. This commit
adapts the remaining modules to use `request.geoip` instead of
`request.session.geoip`.

Geoip is always set on the request but it can be an empty dictionnary in
case the geolocalization failed.

closes odoo/odoo#86015

Task: 2789035
Related: odoo/enterprise#25192
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-04-05 14:13:54 +02:00
Aurélien WarnonandPatrick Hoste ea680d8595 [IMP] im_livechat: introduce chatbot scripts
PURPOSE

This commit introduces a chatbot operator that works based on a user-defined
script with various steps.

SPECS

A im_livechat.chatbot.script can be defined on a livechat rule.
When a end-user reaches a website page that matches the rule, the chat window
opens and the script of the bot starts iterating through its steps.

The chatbot code is currently directly integrated with the existing livechat
Javascript code.
It defines extra conditions and layout elements to be able to automate the
conversation and register user answers.

AVAILABLE STEPS

A script is defined with several steps that can currently be one of the
following types:

"text"

A simple text step where the bot posts a message without expecting an answer
e.g: "Hello! I'm a friendly robot!"

"question_selection"

The bot will ask a question and suggest answers, the end-user will have to
click on the answer he chooses
e.g: "How can I help you?
  -> Create a Ticket
  -> Create a Lead
  -> Speak with a human"

"question_email"

That step will ask the end user's email address (and validate it)
The result is saved on the linked im_livechat.im_livechatchatbot.mail.message

"question_phone"

Same logic as the 'question_email' for a phone number
We don't validate the input this time as it's a complicated process
(requires country, ...)

"forward_operator"

Special type of step that will add a human operator to the conversation when
reached, which stops the script and allow the visitor to discuss with a
real person.

The operator will be chosen among the available operators on the
livechat.channel.

If there is no operator available, the script continues normally which allows
to automate an "answering machine" that will redirect the user in case no
operator is available.

e.g: "I'm sorry, no operator is available right now, please contact us by email
at 'info@company.com', we will try to respond as soon as possible!".
(Or even something more complex with multiple questions / paths).

"free_input_single"

Will ask the visitor for a single line of text.
This text is not saved anywhere else than in the conversation, but it's still
useful when combined with steps that create leads / tickets since those print
the whole conversation into the description.

"free_input_multi"

Same as "free_input_single" but lets the user input multiple lines of text.
The frontend implementation is made by waiting a few seconds (currently 10) for
either the next submitted message or the next character typed into the input.

This lets visitors explain their issue / question with multiple messages.
Which is very useful since new messages are sent every time you press "Enter".

LINKS

Task-2030386

Part-of: odoo/odoo#84000
Co-authored-by: Patrick Hoste <pko@odoo.com>
Co-authored-by: Aurélien Warnon <awa@odoo.com>
2022-04-01 18:49:56 +02:00
Hiral Bhavsar 7bab57a50a [FIX] (im,website)_livechat: visitor country displayed twice in backend
Before this commit:

At least if website_livechat is installed, the livechat visitor (website visitor)
country is displayed twice in channel name: once from the country inside the
name of livechat_visitor and once from the country of the actual
website_visitor.

After this commit:

Livechat visitor country will be displayed only once instead of twice

Task-2668051

closes odoo/odoo#81398

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-03-31 16:27:54 +02:00
Fabien Pinckaers 6b87526048 [IMP] Speed Imp: remove unnecessary base64 encode & decode
Avoid to base64 encode, then decode to process assets and images for a ~25% speed improvement.
Change image processing tool to work on images, rather than base64 encoded strings.

Performance is ~25% faster on assets & images:

  /web/assets/...frontend.min.css:    13ms to 7ms,  base64 enc/dec: 2 -> 0
  /web/image/XML_ID:                  10ms to 8ms,  base64 enc/dec: 3 -> 0
  /web/image/res.users/2/avatar_128:  40ms to 20ms, base64 enc/dec: 6 -> 2

closes odoo/odoo#82851

Related: odoo/enterprise#23537
Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-01-22 11:51:42 +00:00
Victor FeyensandThibault Delavallée f85387ef33 [IMP] mail(_*): limit usage of search
Purpose of this commit is to globally improve code performance by limiting
search impact by

  * adding limits when only first found record id used;
  * avoid unnecessary searches when record set can be filtered instead;
  * using cache when accessing ir.model;

Task-2638444
PR odoo/odoo#76005

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Victor Feyens <vfe@odoo.com>
2021-09-08 07:56:04 +00:00
Xavier-Do fdaee845d5 [FIX] base: remove options parameters
Regarding previous commit, the option parameter can be removed
from _get_asset_content api, followed by a nice snowball effect.

Part-of: odoo/odoo#75248
2021-08-26 10:21:10 +00:00
Julien Mougenot 08bb6e2e50 [FIX] im_livechat: Convert external_lib assets
Before this commit: some assets in im_livechat have not been converted
to the new manifest asset declaration system.

This commit converts these assets.

closes odoo/odoo#69612

X-original-commit: b6e1945a20b69dfc7cf83cd4380e92d949665093
Related: odoo/enterprise#17851
Signed-off-by: Christophe Simonis <chs@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-04-21 15:49:57 +00:00
Thibault Delavallée 62dc6a6173 [REF] mail, mass_mailing, hr, {(website_)im_/crm_}livechat: clean use of channel members in various code place
RATIONALE

Channel model is a mail.thread enabled model behaving strangely with followers,
notifications and discuss. Its code should however be simplified to be more
self contained and avoid unwanted side effects on other models.

SPECIFICATIONS

Purpose of this commit is to better differentiate channel members technical
model from partner members in code :

  * ``channel_partner_ids``: contacts member of a channel, filtering notably
    on active and checking ACLs on res.partner business model. This one
    should be used whenever we deal with members of a channel at business
    level;
  * ``channel_last_seen_partner_ids``: memberships of a channel and technical
    model. This one should be used for internal processes and members
    management;

Also containing

  * clean naming or API of methods managing channel members. This should
    not change anything functionally as only code renaming / cleaning is
    performed;
  * improve performances of channel member auto subscription by aggregating
    all members to add and creating them at once;
  * check the use of ``mail.channel.partner`` and ``res.partner`` records
    through ``channel_last_seen_partner_ids`` and ``channel_partner_ids``
    Channel fields;

Functionally nothing should change with this commit. It only cleans code
in order to prepare future modifications.

LINKS

Task ID-2070632 (main task)
Task ID-2419762 (followup task)
COM PR odoo/odoo#62859
ENT PR odoo/enterprise#15172
UPG PR odoo/upgrade#2005
2021-03-17 18:07:25 +00:00
3fea5b2136 [REF] mail, *: refactor messaging with OWL
This commit is a significant rewriting of client-side discuss, chatter,
chat window, and messaging menu using OWL. The behavior should be broadly
the same, with some slight functional changes here and there.

From a technical standpoint, the code of messaging is mainly organized in 2
main groups of modules:

- models, which are logical entities that depict the client-side state of
  messaging as a whole.
- components, which are in charge of displaying information from models.

This refactoring also introduces new JS guidelines regarding folder structure
(/static) and naming rules for JS modules.

Community PR: https://github.com/odoo/odoo/pull/39023
Enterprise PR: https://github.com/odoo/enterprise/pull/6249

Task-1914207

This PR is a collaborative work by Alexandre, Julien, Sébastien and Xavier,
with the precious help of Lucas to speed it up towards the end.

closes odoo/odoo#39023

Related: odoo/enterprise#6249
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Co-authored-by: Alexandre Kühn <aku@odoo.com>
Co-authored-by: Julien Giannone <jgi@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
Co-authored-by: Sébastien Theys <seb@odoo.com>
Co-authored-by: Xavier Dubuc <xdu@odoo.com>
2020-06-15 18:12:21 +00:00
David Beguin 20a7ae2657 [REF] im_livechat, website_livechat : move close livechat session to base module
In order to be able to flag the livechat as inactive when the visitor left the
conversation, livechat_active field is moved to im_livechat module, as it is
not linked to website_visitor.

This commit is also a preparation for next one, which will implement the close
conversation right after the first click on x button in livechat window (at
visitor side). We needed the livechat_active flag to be available without
website installed.

Task ID: 2120210
PR #39939
2020-02-12 16:06:22 +00:00
Thibault Delavallée 5649fc88e8 [REF] {website_}mail: move and replace published field of mail.message to is_internal
PURPOSE

Clean posting process and improve mail.message definition and comprehension.

SPECIFICATIONS

Website mail defines a website_published field allowing to publish / unpublish
comments on the frontend of some modules. This field has several drawbacks :

  * it is used only for front-end people (portal, public) and has no real
    effect in chatter / classic discussions;
  * it is used only in some advanced front-end module and is not available
    in portal by default;
  * its naming is not really correct as it is not linked to fields coming
    from the website_published mixin and its behavior is not really
    the same;
  * its use is a bit duplicated with internal flag coming from subtype
    allowing to hide messages related to an internal subtype;
  * there are overrides of standard mail.message methods just to handle
    this flag;

In this commit we change that field by an is_internal flag directly on
mail.message model itself. It tells if share people (customers, share users)
are allowed to read the message. This field can be given through posting
API or set manually using widgets. It is also used in access rights custom
methods and managed like the internal flag of subtypes.

Mailgateway was already using an internal flag for internal note replies. It
is renamed to is_internal and propagated as it is now a standard field. It
also eases code understanding.

Portal is updated to allow managing the flag directly. It means customer portal
now natively allows to moderate customer comments without any need of website
modules.

Rating is updated accordingly. An is_internal field is added, replacing the
related on website published.

LINKS

Task ID 2071556
PR #38692
2019-12-02 15:18:44 +00:00
Thibault Delavallée 69ccabb212 [FIX] mail: restrict access to mail.mail model
From now on mail.mail is considered as a technical model. Indeed people should
not really manually craft mails by hand. Instead various functional flows
should either send mails, either craft mails based on some user input.

We therefore make mail restricted to admin users. Flows creating mail.mail
are updated to use sudo, and ensure it was done in a context that makes
sense to delegate this power to the user.

Task ID 1853147
PR #32243
2019-11-29 13:35:14 +00:00
David Beguin 1832d17d21 [FIX] im_livechat, website_livechat: fix use visitor name in livechat session
im_livechat main controller was referring to website.visitor but this module is
not depending on website. The usage of website visitor's name should have been
done in website_livechat module.

This commit fix this issue.

Task ID: 2116715
PR #40732

closes odoo/odoo#40884

X-original-commit: defb98c1083e55ff02f290c3c6257a4ca8dc7d1f
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-11-22 16:32:19 +00:00
David Beguin 8d359aa5a5 [FIX] livechat : use visitor name when visitor start livechat
If the visitor starts a livechat session, his anonymous name was 'Visitor'.
Since visitor info are now stored, we can use the visitor name instead, if a visitor
can be retreived.

Task ID: 2076656
PR #37511
2019-09-30 15:54:48 +00:00
David Beguin 013128699d [FIX] im_livechat : fix send feedback from livechatter.
This commit fixes the send feedback by creating explicitely the
rating.
Before, we gave to the mail channel the rating values.
But as rating uses res_id and res_model, creating the rating
directly with correct values in res_id and res_model makes the magic.
The rating is correctly linked to the mail channel.

Task ID: 2076190
PR #37340
2019-09-24 13:25:50 +00:00
Christophe Simonis 5a273e74f0 [MERGE] forward port branch saas-12.4 up to fe59754c52
closes odoo/odoo#36721

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-13 13:32:51 +00:00
Christophe Simonis 545e6d2034 [MERGE] forward port branch 12.0 up to 52f6e38cea 2019-08-30 17:20:28 +02:00
Christophe Simonis 12e9613f96 [MERGE] forward port branch saas-11.3 up to 668c360e32 2019-08-21 18:26:18 +02:00
Christophe Simonis 668c360e32 [MERGE] forward port branch 11.0 up to 1b234b1be7 2019-08-21 16:58:16 +02:00
Lucas Perais (lpe) 5e3d49bc47 [FIX] im_livechat: livechat rating computes well
Open a livechat session between a visitor and a user
That is, open the / controller as public user, and click,
on the bottom right corner, on "Have a question ? Chat with us."
Exchange at least one message to open the session

From the visitor side, close the window. There is a proposal to rate the discussion
Assign either the green face or the yellow one
(The red one is a bit trickier)

Now, on the user side, check the list view of LiveChat sessions

Before this commit, the rating of those sessions were 0
This is because:
The rating.rating < Many2One > mail.channel link is not a foreign key
(rather, it is composed by char::res_model; Integer::res_id)
and doesn't make the reciprocal field recompute, which in turn doesn't make
our relevant field compute

After this commit, the last_rating field field is recomputed and appear in the list view

OPW 2052964

closes odoo/odoo#35830

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2019-08-20 08:12:32 +00:00
David Beguin 78e6ce3c3f [IMP] website_livechat : allow to send chat request to a website_visitor
This commit allows a livechat operator to send a chat request to a
connected and available website_visitor.

A visitor is considered as connected if his last tracked website.page request
was within the last 5 minutes.
A visitor is available if he doesn't have an active livechat conversation
(mail_channel with type = livechat).
  - If another operator sent him a chat request
  - Or if the visitor asked himself to speak with an operator
    (via the normal and existing flow)

A livechat conversation is active while the visitor haven't left the conversation.
An operator cannot leave a livechat conversation, only the visitor can.

The flow to send a chat request:
  - On the visitor view (tree or form), operator click on 'send chat request'
    (button or livechat icon)
  - A empty conversation with the visitor pops up at operator side.
  - While the operator didn't send a message, the visitor won't see the conversation.
  - The operator can type a message to the user
  - If the operator close the chat without sending any messages,
    the chat request AND the mail_channel are both deleted.
    In this case, the visitor is then available to send him a new chat request.
  - If the operator send a message, at the visitor's next action
    (page navigation on pages that allows livechat, based on livechat rules),
    the conversation will pop up at visitor side, using the livechat button widget.
    The visitor won't be able to request a livechat conversation with an operator until
    he leaves the chat requested by the operator.
  - Once the visitor leaves (with or without rating) the conversation :
        - the operator is notified that the visitor has left the conversation
        - the chat request is deleted to keep the chat request table clean and minimal
        - the livechat conversation if set to inactive.
  - The visitor is now available again to send him a chat request.

This feature uses the already existing livechat_session cookie mechanism,
so no further code modification was needed to make this work.
It's directly integrated is existing livechat flow.

The chat_request model is only useful to quickly check if a visitor has a chat request
and to send the livechat conversation info to the visitor via the livechat_session cookie.

This commit also add a website_visitor banner info on discuss view :

To be able to quickly see all the relevant information of a website visitor
while talking with in discuss view, a fixed banner have been added.
Only the discuss view will benefit from this because detached chatter window
is to small to display such banner.

Task ID: 34624
PR #2028059
2019-08-19 06:33:37 +00:00
mgh-odoo 737746c05c [IMP] im_livechat: allow visitors to get a transcript of their live chat
after this commit user can get a copy of the conversation with operator

task-2029660
closes #34620

closes odoo/odoo#35083

Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-08-14 12:25:12 +00:00
Raphael Collet caf900e89e [FIX] *: use auth='public' in controllers that use request.env
The following trick used to work, because `sudo()` was actually making
an environment for the superuser to operate upon:

request.env[...].sudo().method(...)

It no longer works in general, since `sudo()` now makes an environment
in superuser mode but with `uid=None`!  It may still work by accident
for operations that never use `env.uid`, but is broken in general.

Using `auth='public'` fixes the problem by using the public user when no
user is available.

closes odoo/odoo#34297

Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2019-07-04 11:32:22 +00:00
Aurélien Warnon 594c6e8a2a [IMP] im_livechat: ensure that visitors always gets the same operator
Task #1919871

Purpose
=======

If a visitor comes on the website and launches a livechat, it will be randomly assigned operator A.
If he comes the next day and opens a livechat again, we want him to have the same operator if he's available.

To handle that use case, we added a cookie that stores the "previous operator id" information for 7 days.
2019-04-01 07:03:11 +00:00
Aurélien Warnon c04b9c019e [REF] im_livechat: rework some 'im_livechat.channel' model methods
Purpose
=======

Several methods of the 'im_livechat.channel' model were passed a 'channel_id' to work on.
This has been changed so that the caller can use those methods on an instance of this model instead.

Some methods have also been switched to private because they had no apparent reasons to be public.

This is a preliminary cleaning for task #1919871

Specicial note for the "loader" template:
To load the livechat assets in a website page, the 'loader' template of livechat
is directly called (instead of being returned through a controller) in order
to avoid a new call to server.
As this commit moves 'sudo' to make method callable on the record directly, it
still needs to be sudo. First solution was to add the 'sudo' in the template, which
is a bad practise.
This commit creates a proxy method on website model returning the livechat info
with 'sudo'. This avoid having the 'sudo' done in template. Like always, explicit
is better than implicit.

Task-1919871
2019-04-01 07:03:11 +00:00
Martin Geubelle 7abeaf56b3 [REF] im_livechat, *: remove JSONP in favor of CORS
When embedding the livechat on an external website, we used to make JSONP calls.
As the support of JSONP calls has been dropped, we now use the CORS mechanism
instead.
2019-02-13 09:38:30 +00:00
7d85ab1eac [REF] base, *: refactor binary_content
*: tools, web, website, website_forum, mail, im_livechat

This commit refactors ir_http to make it more readable
and flexible.

Move the resize function of web/image to odoo.tools

Co-authored-by: XavierDo <xdo@odoo.com>
Co-authored-by: Antony Lesuisse <al@openerp.com>

closes: #28563
task: #1908896
2018-12-06 19:09:33 +00:00
David Beguin 2986a5a412 [IMP] im_livechat : add measures to channel report to be used in Dashboard
Adds some indicators in channel report in order to use them in the new
enterprise livechat dashboard. Those indicator are added here to re-use
directly the channel report view. It allows the users to use also those
new indicators in the existing reports.

- No answer indicator
- Days of activity indicator
- Day number indicator
- Country of visitor :
    This makes able to see from which country comes the visitors
    and make statistics with it.

    If no GeoIP server are installed, or if the country is not found,
    or if visitor is logged in but has no country configured, the country
    si set to 'Unknown'.

Also, align sessions and operator report title on menu name

Task ID : 1895998
Closes PR #28283
2018-12-05 14:37:13 +00:00
David Beguin 8c8f219b47 [IMP] im_livechat : uses anonymous name only if visitor is anonymous
Before, if the visitor was logged in, anonymous name = user.name.
But if we use anonymous name field even if visitor is not anonymous,
we cannot know, in stat e.g., if the session was really made with
an anonymous visitor or not as the field is always filled in.

Now, if the visitor is not anonymous, we use directly the user.name
but we do not fill in the anonymous name. So that if anonymous name
is null, we know afterwards that the session was made we a real
anonymous visitor.

Since the anonymous name is empty if visitor is logged in,
we cannot use anonymous_name anymore to get the title of the session window.

Task ID : 1895998
Closes PR #28283
2018-12-05 14:37:10 +00:00
Alexandre Kühn 5f1d32f3fb [IMP] mail, im_livechat: 'is typing...' indicator on mail channels
With this commit, most threads show an indicator when a member is typing
something. e.g.

	"Mitchell Stephens is typing..."

Supported threads:

	- DM
	- (public & private) channels
	- Livechat (Website & Backend)

Unsupported threads:

	- mailboxes (e.g. 'Inbox')
	- document thread (= 'Chatter')
	- support channel (with `im_support` module)

Some technical details:

	- This is a mix between 'start'/'stop' and 'regular notify' strategies.
	- On typing text in composer: notify 'start typing' to all members of
	  thread.
	- On clearing text in composer: notify 'stop typing' to all members of
	  thread.
	- A member can only notify once every 2.5 seconds to the server when he
	  starts or stops typing something (throttled, buffered notify call).
	- On receiving a message from someone that is typing: determine that he is
	  no longer typing.
	- On non-empty and unchanged composer text for 5.0 seconds: automatically
	  notifies all members of thread that he is no longer typing anything.
	  (This is like a 'soft / cooperative sender' timeout).
	- On non-receiving a typing notification of someone after 60 seconds:
	  determine that he is not longer typing something (This is like a
	  'hard / receiver assumption' timeout).
	- When some types for more than 50 seconds straight: notify that he is
	  still typing something (again and again every 50 seconds).
	- When two or more people are typing something (Multi-User channels), it
	  displays at most 2 typing users (ordering rule: longer typers first):

	  	"Mitchell Stephens, Marc Brown and more are typing..."

	- Timing summary:

		- Usually 2.5 seconds uncertainty.
    	- Up to 5.0 seconds uncertainty on typer inactivity.
    	- Up to 60 seconds uncertainty on typer page reload / browser tab
    	  closed / etc.

Future Improvements:

	- Detect page reload or browser tab close with loose of longpolling
	  connection

Task-ID 28188
2018-08-13 14:17:40 +02:00
Christophe Simonis 68326b15f9 [MERGE] forward port branch 11.0 up to c5ed372970 2018-06-21 12:18:40 +02:00
Christophe Matthieu 9cd982bcc8 [FIX] qweb: use cdn for asset files
Refactoring of qweb to call _post_processing_att for each nodes. This
change remove the crappy ovewrite in website module. The website overwrite
only the _post_processing_att to add the cdn parameters.

The static node (without t- attributes) can stay static (remove overwrite
of _is_static_node), the cdn is applied at the compile time for this
nodes instead of at the running time like the dynamic node.
2018-06-15 08:42:15 +02:00
Christophe Simonis 4aa5ec3fa5 [MERGE] forward port branch 11.0 up to d67b410dfc 2018-03-07 18:46:38 +01:00
Lucas Perais (lpe) cf5142e059 [FIX] im_livechat: make /history command work for public user
Have the public user (not logged in -- user B) having a live chat with any logged in user (user A)
Having in mind that:
- (A) issues /history in his chatter to see where (B) has gone on the website
- The bus sends a kind of a "pull cookie request" on each clients
- The browser of (B) retrieves the cookie info and calls the relevant route
- That route sends the transient message for (A)

Before this commit:
The command did not work because the user of the route we end up on is the public one
hence, the search for the channel would not yield anything

After this commit:
The command does work as expected

OPW 1818732
closes #23485
2018-03-07 09:12:47 +01:00