[FIX] mass_mailing: filter emails to avoid duplicates
When subscribing a user to a mailing list, the `mail.mass_mailing.contact` created is processed to identify it's name and email from the address (method `get_name_email` called in `add_to_list` and `name_create`). For a better consistency, the search of existing contacts should also be done using the method `get_name_email`. This avoids that subscribing twice `Example <example@example.com>` fails to detect duplicates and creates two subscriptions. Closes #12265
This commit is contained in:
parent
b49818e1ee
commit
57e5d703c2
|
@ -65,8 +65,12 @@ class MassMailController(http.Controller):
|
|||
def subscribe(self, list_id, email, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Contacts = request.registry['mail.mass_mailing.contact']
|
||||
parsed_email = Contacts.get_name_email(email, context=context)[1]
|
||||
|
||||
contact_ids = Contacts.search_read(cr, SUPERUSER_ID, [('list_id', '=', int(list_id)), ('email', '=', email)], ['opt_out'], context=context)
|
||||
contact_ids = Contacts.search_read(
|
||||
cr, SUPERUSER_ID,
|
||||
[('list_id', '=', int(list_id)), ('email', '=', parsed_email)],
|
||||
['opt_out'], context=context)
|
||||
if not contact_ids:
|
||||
Contacts.add_to_list(cr, SUPERUSER_ID, email, int(list_id), context=context)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue