summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/utils.js
AgeCommit message (Collapse)Author
2021-04-01[FIX] mail: detect a bigger range of URL in messagesDidier (did)
Current URL regexp doesn't support special, but still valid, character like `é`, `è`, `ỗ`, `ặ`, etc. Url like `https://tenor.com/view/chỗgiặt-dog-smile-gif-13860250` are not going to be matched correctly. This commit adds the support for Latin-1 Supplement, Latin Extended-A, Latin Extended-B and Latin Extended Additional unicode. Some relevant stackoverflow discussion: https://stackoverflow.com/questions/20690499/concrete-javascript-regex-for-accented-characters-diacritics task-2088895 closes odoo/odoo#68667 X-original-commit: 1f9c171115d8bbd81d382e353f3faadab16aedfc Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-12-08[FIX] mail: turn tagged name with special characters into linksIvan Yelizariev
STEPS: * Created partner with following name: Putin's spokesman * Tag the partner in a message: @Putin's spokesman BEFORE: tag is not converted into a link AFTER: the link is created WHY: _generateMentionsLinks uses ``owl.utils.escape`` which is different from ``_.escape`` https://github.com/odoo/odoo/blob/880555b38dee0c3e3b364c19bb6b0db983bf8aa0/addons/mail/static/src/models/composer/composer.js#L659 So following replace didn't work: https://github.com/odoo/odoo/blob/880555b38dee0c3e3b364c19bb6b0db983bf8aa0/addons/mail/static/src/models/composer/composer.js#L667 --- opw-2408863 closes odoo/odoo#62893 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-06-26[FIX] mail: replace <br/> by space in thread previewXavier Dubuc
task-2284905 closes odoo/odoo#53718 X-original-commit: 80504fabd43832c5495ded3afc4b364c71d3df70 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-06-15[REF] mail, *: refactor messaging with OWLSébastien Theys
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-01-08[FIX] mail: faster opening of messaging menuAlexandre Kühn
Before this commit, opening the messaging menu might be slow. This was caused by the parsing of bodies of messages with lots of HTML nodes. Indeed, the body of a message is linkified and inlined, and both processes were quite slow due to their implementation: each node in the HTML were recursively parsed and re-assigning `innerHTML`. As a result, each node was triggering an HTML parse, which is very slow on complex nodes. This commit fixes this performance issue by speeding up inlining and linkifying of html strings. In the case of linkify, it now triggers an HTML parse only when necessary, while inlining now relies on its textContent value. These changes should drastically improve the speed of opening and rendering messaging menu, almost ten times faster. Task-Id 2076299 closes odoo/odoo#42949 X-original-commit: 8db0afb50ce0853a6a8ab7ee11dd5ed876abab64 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-10-01[IMP] Prevent reverse tabnabbing in plaintext2html, linkify, _makeLinkSamuel Degueldre
These functions convert plain text links into clickable hyperlinks. These open in new tabs but did not have the "noreferrer noopener" rel attributes, which made them susceptible to reverse tabnabbing. A lot of attack vectors were available to unregistered, uninvited anonymous users and presented a significant phishing threat (such as posting links in the instant-chat, through a mail-alias, in a forum post or in a twitter post) and leading the operator to believe he had been disconnected from odoo in the original tab, prompting them to enter their credentials. while these three places will add the noreferrer and noopener attributes on the anchor tags generated by them, there are still many places that create hyperlinks without the use of these functions, although most of them are static links, they still represent a transitive security vulnerability to the linked sites. There are also a few modules and widgets that roll out their own links or open new tabs unsafely using window.open(), these will need to be patched separately. closes odoo/odoo#37591 Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2019-08-30[MERGE] forward port branch 12.0 up to 52f6e38cea8Christophe Simonis
2019-08-29[MERGE] forward port branch saas-11.3 up to ede253f1b2eChristophe Simonis
2019-08-29[MERGE] forward port branch 11.0 up to d61873ac4a3Christophe Simonis
2019-08-29[FIX] mail: parse message with invalid html as contentFlorimond Husquinet (fhu)
Before this commit, when a message contains invalid HTML, it crashed with error such as: "TypeError: Cannot read property 'childNodes' of null". This commit fixes the issue by wrapping the content of messages with invalid HTML in a `<pre>` tag. OPW-2048140 closes odoo/odoo#36196 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-02-07[IMP] mail: correctly patch mail status manager timersXavierDo
We want to avoid that a `setTimeout` started in one test has an impact on other tests. This is especially true with the status update loop. Since mail_service is used in multiple tests, the safest solution is to patch timeouts everytime we make a call to getMailServices. There is no need for an unpatch, the patch become the default behaviour until the page is refresh at the end of tests. It is possible to manually add the patch after calling `getMailServices` ``` this.services = mailTestUtils.getMailServices(this); this.timeoutMock = mailTestUtils.patchMailTimeouts(); ``` This can be usefull if we want to get the timeoutMock to simulate time changes. Task: 1856205
2019-01-17[MERGE] forward port branch 11.0 up to 19558129f0eChristophe Simonis
2019-01-17[MERGE] forward port branch saas-15 up to c0471dd8579Christophe Simonis
2019-01-17[MERGE] forward port branch saas-14 up to 17adccd95c9Christophe Simonis
2019-01-15[FIX] mail: URL with semi-colonJulien (juc) Castiaux
When posting a URL containing a semicolon, odoo stops the link before the semicolon instead of continuing the link to the end although it is a valid characters in URL (see RFC-3986) e.g. the url "example.com&foo;bar" matches "example.com&foo" instead of the whole link opw-1918367 closes odoo/odoo#30198
2019-01-28[MERGE] forward port branch saas-12.1 up to d3b8422c9c4Christophe Simonis
closes odoo/odoo#30614
2019-01-18[MERGE] forward port branch saas-11.3 up to 4aa153e65cfChristophe Simonis
2019-01-10[Generic] unaccent searchmgh-odoo
- added unaccent search on POS customer/partner and product - moved unaccent from "mail.utils" to "web.utils" - added more character to make function accurate We might use str.normalize(from ES6) but the problem is str.normalize method can not consider some double characters i.e. accented character when normalized it returns 2 normal characters and normalize method returns single character, so here custom unaccent method is used to normalize the string What we can improve here: We can use str.normalize method and check if string is still have unaccented charaters that we can call our unaccent method but this unaccent method is also working and performing well closes odoo/odoo#27671
2018-07-02[REF] mail: JS mail refactoringAlexandre Kühn
---------------------- Summary ---------------------- The purpose of this commit is to improve the JS code of the `mail` module. It applies the new coding guidelines and makes some changes on the design of some modules, such as the old ChatManager module. Here is a short summary of the changes that have been made: 1. New coding guidelines - snake_case to camelCase - prefix private attributes and methods with '_' - jsdoc on most methods - one class per module 2. Rename/Merge some classes - 'chat manager' becomes 'mail manager' (internal) and 'mail service' (external) - 'chat window manager' is now included in mail manager - 'thread' widget now named 'thread widget' 3. New model abstraction for mail objects: - modules 'mail.model.*' - modeling: 0..1 0..1 * * ThreadWindow <------> Thread <-------> Message / \ / \ Thread With Cache Document Thread / | \ / | \ Mailbox Channel Support Channel | | DM - Thread: the superclass of threads. - ThreadWindow: the window component of a thread. - Message: mail objects representing messages. - Thread With Cache: threads that can be used with search view (Discuss app compatible). - Document Thread: represents the thread part of a chatter. - Mailbox: represents what was previously called 'static' channel, e.g. 'Inbox'. - Channel: mail objects representing channels, including livechat. - DM: special kind of Channel for 1:1 communication in the backend. - Support Channel: special channel for im_support module. This new modeling approach let us easily add features on all threads, such as the possibility to put any thread in a small window. ---------------------- Known issues ---------------------- [Already Present in Master] 1. When the Discuss app is in the background with 'Inbox' as the selected Thread, when clicking on a document thread preview in the messaging menu of the systray, the rainbow man appears. 2. When a document with the chatter is in the background, when receiving an inbox notification from this document thread, the document thread is automatically marked as read, which removes the notification right away. 3. Sometimes, opening a DM window from the "blank" thread window does not work. 4. Reply-to feature on Inbox is not working: no message is sent in the document thread. 5. On the first login of admin user with demo data, the inbox counter is wrong (it displays 6, instead of 3). Explanation after investigation: > On page load, it fetches the correct number of Inbox messages (3), but the server notifies of 3 needaction messages right away, so it wrongly assumes these are new needaction messages. > Not possible for web client to detect that these messages should not increment the Inbox counter while keeping same API. 6. Notifications for new document thread messages only work when the user sets 'handle with Odoo' for the Notification Management in the preferences. > due to notifications on the longpoll bus for document thread messages that come from needaction notifications. > requires server-side changes to send notification on the longpoll bus to mentionned user. [New] 7. When receiving a message on a unjoined channel, thread window flickers ('open' > 'close' > 'open') Explanation after investigation: > JS logic: a) On auto-join, ask server to join the channel and get channel infos. b) The info tells the channel is not detached, but JS code makes decision to detach it, and tells server the channel is now detached. c) From (a), server notifies on longpoll bus the state of channel, which is not detached. The web client thinks that the window state of the channel has been changed somewhere else, and the channel is now closed. d) From (b), server notifies on longpoll bus the state of channel, which is detached. The web client opens the thread window of this channel. > The flicker didn't occur before refactoring because the web client was only updating the model of channel when it receives the longpoll notification. > Server behaviour on 1st longpoll notification is necessary for cross-tab synchronization for channel window state. > New design implies that model and view should be synchronized, hence the issue now. > Solution: remove server-side thread window synchronization and replace with client-side synchronization. ---------------------- Hacks ---------------------- The module `im_livechat` now uses mail objects that are compatible with Message and Window objects: Modeling for messages: AbstractMessage / \ / \ LivechatMessage Message - AbstractMessage: message compatible with the thread widget. - LivechatMessage: message used by im_livechat. - Message: message used with the mail manager. Modeling for thread windows: AbstractThreadWindow / \ / \ LivechatWindow ThreadWindow - AbstractThreadWindow: behaviour share between all types of thread windows. - LivechatWindow: window used by im_livechat. - ThreadWindow: window used with mail_manager. The reason for these hacks are twofold: 1. Use the thread widget in the frontend and livechat external lib bundles. 2. Do not have a dependency with the mail manager in the frontend and external lib bundles.
2018-04-23[MERGE] forward port branch 11.0 up to 3ab25b60bc5Christophe Simonis
2018-04-20[FIX] mail: cover more cases for URLsMartin Trigaux
Transifex URLs have an original scheme using #lang, followed by the module or '$' (for any module) and the searched text can be quoted Before this commit the link was cut after https://www.transifex.com/odoo/odoo-11/translate/#fr/, making the link not clicable Closes #24346
2018-03-22[MERGE] forward port branch 11.0 up to 39d9c362c5bChristophe Simonis
2018-03-22[FIX] mail: strip comments when inliningNicolas Martinelli
When an unread message contains conditional html statements, clicking on the discuss tray icon produces a JS traceback. This is due to `node.tagName` being undefined. When inlining, there is no need for these comments. opw-1829641
2018-02-22[MERGE] forward port branch saas-11.1 up to e750bb6e114Christophe Simonis
2018-02-19[FIX] mail: IP domain name when linkifyingNicolas Lempereur
In chatter, also linkify URL with IP address as domain name like it may be in other part of Odoo (eg. plaintext mail received). With this change, an URL: http://192.168.0.1:8069/web would be linkified. opw-816175 closes #23153
2018-02-01[REF][IMP] *: mail js refactoringAaron Bohy
This commit improves the JS code of the mail module, which comes maily from the new coding guidelines and the addition of "JS services". JS services are important objects that do not fit well in the component tree, such as chat_manager or ajax. The benefits of JS services are improved readability of the code, reduced coupling, and more testable modules. In particular, discuss was hard to Summary of the changes: - ClientAction has been renamed into Discuss - Clear instantiation of chatManager - New coding guidelines in most mail modules - JS Services can interact with each other - Chat Manager and Window Manager are services - Window Manager renamed to Chat Window Manager - bus.bus is now encapsulated in Bus Service (a service) - The test infrastructure has been tweaked with JS Services - Chat Mixin has been removed A future improvement would be to translate some 'trigger' into 'trigger_up'.
2018-01-19[MERGE] forward port branch saas-15 up to 0c54862cbf1Christophe Simonis
2018-01-16[FIX] mail: Cannot send new message from Event TrackGoffin Simon
When the Speaker address is False, it crashed. opw:805361
2017-04-18[MERGE] forward port branch saas-15 up to 780064ea89dChristophe Simonis
2017-04-13[FIX] mail: error notification safari iphone 7Nicolas Lempereur
On safari iphone 7 (and possibly other browsers) we could have an error by referencing to an undeclared Notification variable. opw-726084
2017-04-11[REF] web, *: redesign all JS viewsGéry Debongnie
This commit introduce a full redesign of all JS views. We started basically from scratch. The goal was to unify all the various views under a common framework, to make them testable, to make then usable in different conditions (in studio, or in the frontend), and to make our lives easier. Some important points are: - we introduced new coding guidelines (camelCase, 80 chars width, ...) - we have a brand new testing framework (still QUnit based) - kanban view moved to the web addon - calendar view (formerly web_calender) moved to web as well - the tree view was removed - all new code should be documented We hope that this code is the start of a new era for the Odoo web client, we want to have a high quality codebase, well documented, well tested, well designed. Work done by the framework team: mostly aab, ged, chm, dmo, qsm
2017-03-13[MERGE] forward port branch saas-11 up to 2e972578b92Christophe Simonis
2017-03-13[MERGE] forward port branch 9.0 up to 73d6f9023afChristophe Simonis
2017-01-13[FIX] mail: trim '()' charactersNicolas Martinelli
In commit 07425d407f9 a trim of some special characters was introduced to prevent a crash. This was necessary in v9, but it is not in v10. opw-703465
2016-12-26Revert "[FIX] mail: livechat escaping"Nicolas Lempereur
This reverts commit 1c60a631df8b42b90973e117eae5d510fcc0f223. The fix was done to conciliate 83956d4 and ff56304f5 but ff56304f5 was forward-ported erroneously and introduced other issues. opw-702410
2016-12-23[FIX] mail: livechat escapingNicolas Martinelli
- In a livechat window, type a URL, then end by a space. For example, type "https://odoo.com " (whithout quotes) - Press enter It is converted into "https://odoo.com&nbsp;". opw-702410
2016-11-10[IMP] mail.utils: refactor url to link helper so it can be used on a strFabien Meghazi
2016-06-08[MERGE] forward port of branch saas-10 up to 2f948c7Christophe Simonis
2016-06-02[FIX] mail: fix native notificationsGéry Debongnie
because of a previous refactoring, the function send_notification stopped working at all. It was not using the instance of the bus, but the module containing the bus instance.
2016-03-09[IMP] mail: load audio file lazilyGéry Debongnie
2016-03-02[REF] mail: code refactoringAaron Bohy
- extended_chat_window feature in its own files: as it is only available in the backend, we don't want it in the frontend assets (which contain the 'basic' chat_window) - move followers feature in its own files - creation of the 'mail.utils' module in utils.js - creation of systray.less to define the style of the mail item and dropdown in the navbar - use of chat_manager's search_partner function in PartnerInviteDialog - some code linting