Commit Graph
144 Commits
Author SHA1 Message Date
Aaron Bohy 54396cfa41 [FIX] im_livechat,mail: don't automatically detach chat channels
This reverts commit a8239cd as the navbar dropdown recently introduced now
offers a quick access to channels without coming back in the Discuss App.

Moreover, this commit emphasizes the notifications navbar icon when there are
unread messages (or at least, it mutes it when there isn't).
2016-01-14 11:22:26 +01:00
Aaron Bohy 916d90af35 [IMP] mail: open dm shortcut from in navbar dropdown
Allows to directly open a dm channel from a chat window, without coming back
to Discuss.
2016-01-14 11:22:26 +01:00
Aaron Bohy b3868a613c [IMP] mail: needaction/unread messages counters
Some UI changes:
  - Unread messages in chat are now displayed as needactions in the Discuss's
sidebar (badge with counter of unread messages, instead of simply bolding the
channel name).
  - The counter displayed in the navbar is now the sum of needactions and total
of unread messages in chat.
  - The counter displayed next to Inbox is still the needaction counter.

For consistency between tabs/browsers/devices, the channel_seen info is now
broadcasted, meaning that every tab/browser/device will be noticed.

Also now correctly increment the unread counter of a channel if the received
message is a needaction.
2016-01-14 11:22:25 +01:00
Aaron Bohy d93231afe2 [IMP] mail: navbar: messaging menu
The navbar notification is now a dropdown containing a preview of all pinned
channels (except Inbox and Starred), channels with unread messages being on the
top.

It allows to quickly detach a channel without going back to Discuss.

The channels preview fetching is performed only once, and it is done in
background without blocking the whole UI (using shadow option or session.rpc()).

Also fixes a synchronization problem between server and client about the folded
state of channels (the info wasn't stored client side, so it produced weird
situations, e.g. unfolding a channel didn't actually unfold it).
2016-01-14 11:22:25 +01:00
Christophe Simonis 499c2b8da5 [MERGE] forward port of branch saas-6 up to 580389a 2016-01-08 18:26:59 +01:00
Thibault Delavallée a69c2bab0a [FIX] mail, mail_channel: recipients of channels
Mailing lists (mail.channel) should not send specific notification emails.
Indeed there can be a lot of recipients and customizing each email can
take time to compute. This leads to posting a message on a mail.channel
being very slow.

It is now possible for a model to customize the notification email
recipients computation. The first use is to ensure that mail.channel
encodes recipients using email_to instead of recipients_ids. This way
less processing is performed on notification emails.

This is a manual cherry-pick of commit d4a1eb4435
that was not forard ported. Mail has indeed evolved since 8.0 and its
forward port was not an easy task.

This commit also includes the fix of mail.channel recipients. All are now
considered as equal and receive a simple notification email. No distinction
is done between partners and users. The notification emails for channels
should be as simple as possible.
2016-01-08 16:40:40 +01:00
Géry Debongnie 739301be09 [FIX] mail: add link to urls clientside, not serverside
the server should avoid as much as possible modifying emails.  Adding
links is a presentation concern, so this commit moves this logic client
side.
2016-01-08 15:02:22 +01:00
Aaron Bohy dfdd38e3b2 [FIX] mail: Discuss: don't suggest to join private channels
Problem was that administrators have access to every channels, even private
channels they are not registered to, because when trying to join an existing
channel, the autocomplete proposed every channels accessible for the user, but
didn't filter private ones.

This rev. makes sure to only suggest non-private channels.

Also prevent '|' domain injection to disable filters (odoo/odoo@44e65e72d3)
by using expression.py to build domain.
2016-01-08 14:32:51 +01:00
Aaron Bohy 0fbc128033 [FIX] mail: followers: subtypes: correctly notify channels
Except for messages, activities on a document like internal notes posted
trigger notifications to partners and channels following the corresponding
activity's subtype.

Rev. 69ed801 rightly re-introduces a filter on followers to prevent notifying
more partners than necessary. Unfortunately, this filter doesn't take into
account channels, which are thus automatically removed from followers to
notify, whatever the subtypes they follow, e.g. internal notes on a document
don't appear in channels following the 'Note' subtype of this document.

This commit makes sure that channels always pass through that filter, but warns
users that public channels should probably not following internal subtypes.

Also makes the edit subtypes dialog html valid (li's must be inside, e.g., ul).
2016-01-08 14:32:51 +01:00
Martin Trigaux 44e65e72d3 [FIX] mail: ignore abritrary argument domain for searching channel
We should not trust arbitrary arguments from public method to compose a domain
as it is possible to inject '|' to disable filters and be able to search any
channel (mitigated by access rules).
Create a private method and use a wrapper that ignores the domain.
2016-01-08 10:07:38 +01:00
Martin Trigaux 8b4f052a38 [MERGE] Forwardport of branch saas-6 up to c649bb0df 2016-01-05 18:28:06 +01:00
Aaron Bohy 30003dbce3 [FIX] im_livechat,mail: various ui fixes/improvements
im_livechat:
  - feedback message wording
  - livechat_channel form view typo

mail:
  - channel form view: email_send field label wording and layout
  - notifications preview extended
  - client action mass mailing composer fine tuning
  - client action mass mailing channels tooltip
  - client action idle bullet color
2015-12-28 10:19:22 +01:00
Thibault Delavallée 52e18acbc8 [FIX] mail: res_users: context update in create
Context was a new one instead of updating the existing one. This was
preventing a correct context propagation.
2015-12-18 13:30:13 +01:00
Aaron Bohy 17896a92da [FIX] mail: various ui improvements/fixes
* chat windows:
  - input was kicked out of the window on chrome 43
  - don't animate if folded by default (e.g. after a refresh)
  - width and height 100% like in the frontend
  - z-index to make sure that they are over bootstrap active btn,
    but below notifications, and modals

* chatter:
  - internal note: send button renammed to 'Log'
  - send button is the first button again
  - remove annoying form view widget's tooltip

* client action: focus on composer on channel change
2015-12-15 10:01:21 +01:00
Thibault Delavallée 27fdcdf982 [FIX] mail: correctly compute recipients number
Otherwise all emails are scheduled in the queue.
2015-12-11 10:29:44 +01:00
Olivier Dony 3d32e99665 [FIX] mail.thread: optimize lookup of res.users by email
Searching on res.partners with domain [('user_ids' , '!=', False)]
will currently be translated into a huge "ID IN <...>"  query,
with the IDs of all existing users.
On a database with a lot of users, this can be measured
in seconds (e.g. 3-4 seconds with 500k+ users),
leading to significant delays in email delivery.

Using a direct lookup in res.users is more direct and faster.
2015-12-10 18:43:17 +01:00
Denis Ledoux 4bebbfdcf5 [FIX] mail: jinja2 code compatible with wysiwyg for notifications
When editing an email template with the wysiwyg,
the `<` and `>` operators are automatically converted
to `&lt;` and `&gt;`, even for the Jinja2 conditions,
therefore breaking these conditions, and the render
of the email templates.

We avoid to use these operators in the email
template, so users can customize the notification
email template without having an advanced
knowledge on how to edit an email template containing
Jinja2 code.

Besides, the line return at the end of the email template,
just after the `% endif`,
is done on purpose as well: the wysiwyg adds automatically,
at the time of this revision,
`<p></p>` at the end of the email template source, but
this cannot be added on the same line than `% endif`,
otherwise this is considered as Jinja2 code, and it's not.

opw-659113
2015-12-10 16:58:15 +01:00
Cedric Snauwaert 5fd3a0446b [FIX] mail: remove classes from short_body and body likewise 2015-12-09 15:24:34 +01:00
Thibault Delavallée f7c0480dc1 [FIX] mail: fix 504227cca9
Do not restrict followers-based alias to members of non public channels.
Otherwise you may have issues defining a public mailing list with a
subscription step. People still wouldn't be able to post on a public
channel using a restricted alias.
2015-12-09 09:59:04 +01:00
Thibault Delavallée e7f842948f [FIX] website_mail_channel: wrong override
message_get_email_values is declared as receiving cr, uid, id. However this method
is an override of a multi method. A decorator has been added to tell that id is
actually a list of ids and avoid list encapsulation issues with the result. This
way the method parameters are not changed.

[CLEAN] mail: removed some unused imports, by the way
2015-12-08 16:33:54 +01:00
Thibault Delavallée a13323be65 [ADD] mail: channel is_member field
This computed field allows to know whether the current user is a channel
member or not. This is necessary to fix the join / leave action button
on channels. It was still based on the followers and has not been updated
with the new v9 model of channel members.
2015-12-08 16:33:53 +01:00
Thibault Delavallée 504227cca9 [FIX] mail: followers restricted alias
Now that channels can follow documents, restricted aliases are a bit too
restricted. We consider that followers-based aliases accept emails from
the direct followers (message_partner_ids) or member of non public
channels (message_channel_ids, filetered public field). This way we avoid
having public channels added by mistake, leading to information leak.
2015-12-08 16:33:49 +01:00
Aaron Bohy 88c5a90677 [FIX] mail: allow users to unsubscribe from private channels
Before this rev., only the root user was allowed to do so, because some
operations were performed on the channel just after the user had been
unsubscribed (to trigger the unsubscribe notification on the bus, and to post
the 'left channel' message).
2015-12-07 16:32:27 +01:00
Aaron Bohy 8017a9569c [FIX] mail: ondelete cascade on mail_channel_partner relation
The problem occurred when the im_livechat cron 'cron_remove_empty_session'
removed empty livechat channels (a public user clicked on the livechat button,
creating a new channel, but never sent any message in it). The empty channel
was deleted by the cron, but the two records in the mail_channel_partner
relation table (linking the channel with the public user and the livechat
operator) wasn't removed, and the value of their field 'channel_id' was None.

When this happenned, it broke the SQL query of 'channel_search_to_join()', the
RPC call performed when clicking on '+' new to public channels in the client
action, resulting in no result displayed in the dropdown.

With this fix, records in the relation table are automatically deleted when
their corresponding channel or partner is deleted.
2015-12-03 11:21:47 +01:00
Géry Debongnie 2c84cd4181 [FIX] mail: various improvements/fixes
- display appropriate message when no results are found in a search
- don't display 'you have been invited' notif when creating private channel
- correctly join when a user was invited in a public channel
- display a message when a user join a channel through an invitation
- don't display subject for message of type notification (still a
  mystery why it happens in test.odoo.com for channel of type mailing)
- better heuristic on when to display message subject
- tweak sidebar text color (slightly whiter)
- add ... to the placeholder of the text area in the composer
- invert send and icons for attach/smiley in composer
- don't display 'read less' on expanded messages
- exclude livechat channels from channel mention suggestions
2015-11-27 11:47:34 +01:00
Aaron Bohy db8203c27a [FIX] base,hr,mail: prefetch mention suggestions
The purpose of this commit is to improve the overall performance of the mention
mechanism of the client action and chatter composer, by pre-fetching some data.

First, the employees are fetched at chat initialization (basically, at web
client initialization), if hr is installed.

Second, when focusing on the composer of a channel, the members of this channel
are fetched. In the case of a chatter, the members are already known as they
are the followers of the document.

When the user types a mention, we first display suggestions from the pre-fetched
partners, and we only perform an RPC when there are no more result matching the
search string. This RPC searches among user, and then partners if there aren't
enough matches.

A few side changes occurred:
  - auto_join set to True on user_ids field of res.partner to boost the query
    that searches partners that are users
  - the '/mail/read_followers' route now returns follower's email as well, as
    we need it for the mention;
  - a partner can now be mentionned several times in the same message;
  - mentionned partner previsualization has been removed, mainly because of
    the previous point, but also because it simplifies the code;
2015-11-27 11:47:34 +01:00
Damien Bouvy 111b3838dc [FIX] mail: store expiration data w/ correct group 2015-11-25 18:13:01 +01:00
Christophe Simonis 56a442e205 [MERGE] forward port of branch saas-6 up to dade7e3 2015-11-25 13:26:02 +01:00
Géry Debongnie 919179b417 [FIX] mail: opening a chatter mark all messages as read
also, send correct notifications in case several channels are concerned.
2015-11-23 16:29:08 +01:00
Aaron Bohy faf5cea948 [FIX] mail: various UI improvements
- emoji are no more clickable in threads (they are only in the popover)
- correctly update channel needaction counter
- don't display 'New message' notification when the channel in detached
- display in the ui channels that send emails and other channels
- prevent notifications in mass mailing channels
- increase bottom padding in client action thread
2015-11-23 16:29:08 +01:00
Thibault Delavallée 007e217c54 [FIX] website_forum: new mail api
set_message_read has been removed from the mail api. It is replaced by
set_message_done. Thanks Lorenzo Battistini.
2015-11-23 11:01:57 +01:00
Aaron Bohy a8239cd2ae [FIX] im_livechat,mail: detach chat on the receiver side
This commit concerns DM and livechat channels. Those channels are now
automatically detached on the receiver side. This allows users to directly
reply to DM's or livechats without coming back to the client action.

Note that they aren't detached if the user previously manually closed the
channel's chat window.
2015-11-20 15:48:03 +01:00
Aaron Bohy c2dfea5cc9 [FIX] mail: correctly load livechat channels
The livechat channels returned by the chat_manager's initial RPC were ignored.
Livechat channels thus weren't persistent in the client action.

This rev. cleans the returned object 'channel_slots' so that it only contains
arrays of channels. The additional mapping and partners array were useless as
the information they contained was directly stored in the DM channels.

We now simply iterate on each array returned and add each channel it contains,
including livechat channels.
2015-11-20 15:48:03 +01:00
Aaron Bohy 1dfd1bd7a3 [FIX] mail: correctly pin DM's on message post
DM channels are supposed to be pinned on each partner's side when a message
is post in the DM. This didn't work because we checked if the channel is a DM
by comparing its type to 'direct_message', which is not a valid channel type.

Also stop marking the DM as pinned in channel_join_and_get_info() as it is now
useless.
2015-11-20 15:48:02 +01:00
Thibault Delavallée 104826c311 [FIX] mail: subtypes read as sudo
Indeed portal and public users may have to read internal subtypes to perform some
check in the code.  However the rules do not allow them to read those internal
subtypes. We have to read some subtypes as sudo then.
2015-11-20 11:25:17 +01:00
Aaron Bohy d519ce5596 [FIX] mail: channels: don't send email by default
Disable this option by default as it might be very costly on channels with a
lot of members. Should be manually set to true on massmailing channels.
2015-11-19 08:16:56 +01:00
Thibault Delavallée 870c822ac5 [FIX] mail: incoming email parsing
Correctly flag and remove nodes to remove containing odoo buttons.

Backport of revision aece706603 of saas7.
2015-11-18 17:23:26 +01:00
Denis Ledoux 49a0eae805 [FIX] mail: mails fetch
`node.get('class', '')` returns a `Nonetype`
in some cases, and, therefore,
`'o_mail_notification' in node.get('class', '')`
throws a
`TypeError: argument of type 'NoneType' is not iterable`.

Replacing by `(node.get('class') or '')` keep the behavior
that was expected, but will prevent to have a `Nonetype`

opw-656508
opw-656753
opw-653965
2015-11-18 17:02:13 +01:00
Thibault Delavallée 2e583eb7c9 [FIX] mail: chatter: re-re-add the read more / less
The read more / read less in chatter has been removed in the new timeline and
then cleaned timeline introduced at cc6d2aa995.
This feature has been brought back at revision 486aab5098.
However a new cleaning removed the feature at revision 2a5f07e0b9.

This commit brings back this feature for the second time. Next one brings free
cookies.
2015-11-18 13:48:27 +01:00
Thibault Delavallée e01e24aa9c [FIX] mail: chatter: subtype when tracking
When having a tracking, the subtype description should be displayed. This is
used for tracking linked to a subtype like Task Opened, Task Blocked, ...

This feature was forgotten when refactoring the chatter for v9 and is now
back.
2015-11-18 13:48:27 +01:00
Damien Bouvy 608b2f7fba [IMP] mail: update notifications sends/receove Odoo Enterprise information
Our servers now accept contract codes and answers with expiration date and expiration reason.
2015-11-17 13:01:09 +01:00
Thibault Delavallée 69ed801979 [FIX] mail: internal note recipients
In some cases internal notes could be sent to more people than expected.
The correct list of recipients was computed but not assigned. Doo.
2015-11-17 10:49:20 +01:00
Aaron Bohy eae08d39d6 [FIX] mail: mark as read: notify correct partner
When calling 'set_message_done' on a message which is a needaction for several
partners, the method was executed as root. This was an issue for the triggered
notification, as it was thus always sent to the admin.

For example, when Demo user marked such a message as read, he never received
the notification, but the Admin did, and its notification counter weirdly
decreased, while the one of Demo user remained the same.
2015-11-17 10:06:18 +01:00
Aaron Bohy c51af45384 [FIX] mail: various UI improvements
- vertically center date and messages separators in threads
- remove notifications in DM and livechat
- order mail demo data so that messages appear ordered (they are ordered by id)
- make sure that DM are pinned (they weren't on the receiver side)
- don't display DM until a message has been sent
- validate message body
- undo snackbar fine tuning
- fix Firefox scroll bug on sidebar rendering (the scroll position was often
  lost when the sidebar was re-rendered, seemingly because the width of the
  thread changed for a brief moment)
2015-11-17 10:06:18 +01:00
Denis Ledoux c2a6aeb244 [FIX] mail: internal subtypes with special characters
The fields options in the form are evaluated with
a `py_eval`, see:
https://github.com/odoo/odoo/blob/3c2e48423b4f9706216cada549d0a725f2dd07d2/addons/web/static/src/js/views/form_common.js#L664,
not as a JSON.

This was changed in October 2012, with rev.
c538db258a

Therefore, the field options must not be passed as a JSON, but
as a Python dict.

This had as side-effect to uncorrectly load the internal
subtypes for the "log a note" feature. For instance,
French translations with accents were displayed incorrectly.

opw-656409
2015-11-16 16:38:54 +01:00
Géry Debongnie bac5a19451 [FIX] mail: various small UI tweaks/fixes
- put the mentionned partners and the attachment above the composer
  instead of below
- debounce some links in thread.js to prevent double loading views when
  double-clicking
- readd the # in front of the channelname of the title of the client action
- give the channel_id to the thread in a chat window, so it does not
  display the channel name everytime it displays a message
- correctly close dm chat window when the dm channel is closed in the
  main sidebar
- simplify the help messages when a channel is empty
2015-11-12 08:51:56 +01:00
Aaron Bohy 5264ccf0d0 [IMP] mail: needactions and messages read
Mainly concern the client action:
	- Display needactions per channels
	- For all channels except Inbox, clear needactions when opening the channel
	- Add snackbar to undo needactions clearing
	- Display a separator between read and unread messages in threads
	- Fix active channel (for Inbox and Starred) display in sidebar

Various minor changes in chat_manager:
	- Code refactoring of bus notification handler
	- get_channel() don't fallback anymore on first channel
2015-11-12 08:51:56 +01:00
Géry Debongnie 622bd038e4 [FIX] mail: various ui improvements
- display star/mark as read icon next to the message title instead on
  the far right
- display unstar all message in channel starred
- enable/disable the 'unstar all' and 'mark read' buttons depending on
  the number of messages in the corresponding channels
- display star on the left sidebar in 'squashed messages'
- tweaks to padding in client action
- display hash in channel name in lighter tone
- light opacity in sidebar
- star icon in message sidebar is clickable + small less refactoring
- message sidebar is aligned with the message now
- messages are not squashed in inbox/starred
2015-11-09 16:36:52 +01:00
Géry Debongnie 2bb55ecb04 [FIX] mail: issue when leaving channel and refreshing
When we refresh, the bus will send the last notifications since the last
50s, so, the browser will receive notifications from a channel that we
already left.  This commits tries to fix the issue by sending
explicitely the information that a channel was unsubscribed.

Also, and this is touchy, it ignores messages received in a channel that
it is not subscribed to (before, it joined the channel)

Also, it will synchronize channels opened and closed in various
tabs/browsers.
2015-11-09 16:36:29 +01:00
Géry Debongnie 62829ac364 [FIX] mail: avoid duplicate entries in model mail.channel.partner
in some cases, it is possible to call the method
channel_join_and_getinfo when the user is already in the channel.  This
may (and did) cause issues in some unrelated code.  This commit
guarantees that this codepath will avoir creating another entry.

Another way to achieve this result is by adding a constraint on the
model mail.channel.partner, but this is in 9.0, so we must be careful.
2015-11-04 16:31:44 +01:00