Skip to content

Commit

Permalink
fix CC issue
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Jul 5, 2024
1 parent bde4e1c commit a4d8b1a
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions app/models/concerns/smooch_menus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ def send_message_to_user_with_main_menu_appended(uid, text, workflow, language,
workflow ||= self.get_workflow(language)

# Main section and secondary menu
ret_main, counter, number_of_options = self.adjust_main_section_and_secondary_menu(workflow, counter, number_of_options)
main.concat ret_main

# Languages and privacy
ret_main, counter, number_of_options = self.adjust_languages_and_privacy(language, counter, number_of_options)
main.concat ret_main

# Set extra and fallback
extra, fallback = self.smooch_menus_set_extra_fallback(main, text, language)

self.send_message_to_user(uid, fallback.join("\n"), extra, false, true, event)
end

def adjust_main_section_and_secondary_menu(workflow, counter, number_of_options)
main = []
allowed_types = ['query_state', 'subscription_state', 'custom_resource']
['smooch_state_main', 'smooch_state_secondary'].each_with_index do |state, i|
rows = []
Expand All @@ -40,8 +55,11 @@ def send_message_to_user_with_main_menu_appended(uid, text, workflow, language,
rows: rows
}
end
return main, counter, number_of_options
end

# Languages and privacy
def adjust_languages_and_privacy(language, counter, number_of_options)
main = []
rows = []
languages = self.get_supported_languages
title = self.get_string('privacy_title', language, 24)
Expand All @@ -66,7 +84,10 @@ def send_message_to_user_with_main_menu_appended(uid, text, workflow, language,
title: title,
rows: rows
}
return main, counter, number_of_options
end

def smooch_menus_set_extra_fallback(main, text, language)
extra = {
override: {
whatsapp: {
Expand Down Expand Up @@ -113,8 +134,7 @@ def send_message_to_user_with_main_menu_appended(uid, text, workflow, language,
extra = { actions: actions }
fallback = [text]
end

self.send_message_to_user(uid, fallback.join("\n"), extra, false, true, event)
return extra, fallback
end

def adjust_language_options(rows, language, number_of_options)
Expand Down

0 comments on commit a4d8b1a

Please sign in to comment.