Skip to content

Commit f81866f

Browse files
committed
[FIX] sms_marketing: ensure SMS links use the correct domain
Before this commit, the generated SMS link did not include the SMS code because it was created using the domain of the second website instead of the intended one. This happened because the comparison was made against the `web.base.url` parameter instead of the current website domain. With this fix, the system correctly uses the current website domain for both link generation and comparison, ensuring the correct domain is applied. Steps to reproduce: - Go to **SMS Marketing**. - Create a new `mailing.mailing` with **Concat Recipients**. - Set up **two websites** with different domains. - Configure `web.base.url` using the same domain as the **first website**. - Log in to the **second website**. - Send the `mailing.mailing`. Expected behavior: - The SMS link should include the correct domain and the SMS code. odoo#201641
1 parent d4d64d6 commit f81866f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

addons/mass_mailing_sms/models/sms_sms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ def _update_body_short_links(self):
1616
""" Override to tweak shortened URLs by adding statistics ids, allowing to
1717
find customer back once clicked. """
1818
res = dict.fromkeys(self.ids, False)
19+
base_url = self.env['website'].get_current_website().get_base_url()
1920
for sms in self:
2021
if not sms.mailing_id or not sms.body:
2122
res[sms.id] = sms.body
2223
continue
2324

2425
body = sms.body
2526
for url in set(re.findall(tools.TEXT_URL_REGEX, body)):
26-
if url.startswith(sms.get_base_url() + '/r/'):
27+
if url.startswith(sms.get_base_url() + '/r/') or url.startswith(base_url + '/r/'):
2728
body = re.sub(re.escape(url) + r'(?![\w@:%.+&~#=/-])', url + f'/s/{sms.id}', body)
2829
res[sms.id] = body
2930
return res

0 commit comments

Comments
 (0)