Skip to content
Snippets Groups Projects
Commit 41f59a61 authored by ijas ahammed's avatar ijas ahammed
Browse files

[FIX] link_tracker,test_mail_full: fix traceback while converting links


Currently, when we try to shorten the links from content with help of
`_convert_links_text` method, it throws traceback if the body(content)
we pass is `False`(might happen when we directly pass a model field of
textual type but the field doesn't have a value yet). It's because
the `re` expects the content to be string / bytestring.

This commit fixes the issue by adding a check in this method, which
will simply return `False` if there's no body.

Task-2628586

closes odoo/odoo#75920

Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent 28e1ba46
Branches
Tags
No related merge requests found
......@@ -178,6 +178,8 @@ class LinkTracker(models.Model):
return html
def _convert_links_text(self, body, vals, blacklist=None):
if not body:
return body
shortened_schema = self.env['ir.config_parameter'].sudo().get_param('web.base.url') + '/r/'
unsubscribe_schema = self.env['ir.config_parameter'].sudo().get_param('web.base.url') + '/sms/'
for original_url in re.findall(TEXT_URL_REGEX, body):
......
......@@ -90,6 +90,9 @@ class TestSMSPost(test_mail_full_common.BaseFunctionalTest, sms_common.MockSMS,
})
link = self.env['link.tracker'].search([('url', '=', link)])
self.assertIn(link.short_url, new_body)
# Bugfix: ensure void content convert does not crash
new_body = self.env['link.tracker']._convert_links_text(False, self.tracker_values)
self.assertFalse(new_body)
def test_body_link_shorten_wshort(self):
link = 'https://test.odoo.com/r/RAOUL'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment