Skip to content

Commit

Permalink
"Unsubscribe" the user from the newsletter language, not the current …
Browse files Browse the repository at this point in the history
…language. (#2150)

When a tipline user is interacting with the bot in a certain language but clicks on the "Unsubscribe" button from a newsletter, the affected subscription should be the one related to the newsletter language, not the current language.

So, the first here is to use the language stored in the delivered message reference, not the current language, which is still used as a fallback.

Fixes: CV2-5252.
  • Loading branch information
caiosba authored Dec 5, 2024
1 parent 8383796 commit bd4c1f5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/concerns/smooch_resend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_information_from_clicked_template_button(message, delete = false)
info = Rails.cache.read("smooch:original:#{quoted_id}").to_s
begin
original = JSON.parse(info)
info = ['newsletter'] if original['fallback_template'] == 'newsletter'
info = ['newsletter', original['language']] if original['fallback_template'] == 'newsletter'
rescue
info = info.split(':')
end
Expand All @@ -138,6 +138,7 @@ def template_button_click_callback(message, uid, language)
self.send_message_on_template_button_click(message, uid, language, info)
when 'newsletter'
team_id = self.config['team_id'].to_i
language = info[1] || language
self.toggle_subscription(uid, language, team_id, self.get_platform_from_message(message), self.get_workflow(language)) if self.user_is_subscribed_to_newsletter?(uid, language, team_id)
end
end
Expand Down

0 comments on commit bd4c1f5

Please sign in to comment.