diff --git a/app/models/concerns/smooch_messages.rb b/app/models/concerns/smooch_messages.rb index 6b09835376..e9bc5ea8a9 100644 --- a/app/models/concerns/smooch_messages.rb +++ b/app/models/concerns/smooch_messages.rb @@ -286,7 +286,7 @@ def handle_bundle_messages(type, list, last, app_id, annotated, send_message = t if ['timeout_requests', 'menu_options_requests', 'resource_requests', 'relevant_search_result_requests', 'timeout_search_requests'].include?(type) key = "smooch:banned:#{bundle['authorId']}" if Rails.cache.read(key).nil? - [annotated].flatten.uniq.each_with_index { |a, i| self.save_message_later(bundle, app_id, type, a, i * 10) } + [annotated].flatten.uniq.each_with_index { |a, i| self.save_message_later(bundle, app_id, type, a, i * 60) } end end end @@ -320,7 +320,7 @@ def supported_message?(message) def save_message_later(message, app_id, request_type = 'default_requests', annotated = nil, interval = 0) mapping = { 'siege' => 'siege' } queue = RequestStore.store[:smooch_bot_queue].to_s - queue = queue.blank? ? 'smooch' : (mapping[queue] || 'smooch') + queue = queue.blank? ? 'smooch_priority' : (mapping[queue] || 'smooch_priority') type = (message['type'] == 'text' && !message['text'][/https?:\/\/[^\s]+/, 0].blank?) ? 'link' : message['type'] SmoochWorker.set(queue: queue).perform_in(1.second + interval.seconds, message.to_json, type, app_id, request_type, YAML.dump(annotated)) end diff --git a/app/models/concerns/smooch_search.rb b/app/models/concerns/smooch_search.rb index 42eb220830..5d01ae89ab 100644 --- a/app/models/concerns/smooch_search.rb +++ b/app/models/concerns/smooch_search.rb @@ -221,12 +221,12 @@ def send_search_results_to_user(uid, results, team_id) language = self.get_user_language(uid) reports = results.collect{ |r| r.get_dynamic_annotation('report_design') } # Get reports languages - reports_language = reports.map{|r| r&.report_design_field_value('language')}.uniq + reports_language = reports.map { |r| r&.report_design_field_value('language') }.uniq if team.get_languages.to_a.size > 1 && !reports_language.include?(language) self.send_message_to_user(uid, self.get_string(:no_results_in_language, language).gsub('%{language}', CheckCldr.language_code_to_name(language, language)), {}, false, true, 'no_results') sleep 1 end - reports.each do |report| + reports.reject{ |r| r.blank? }.each do |report| response = nil response = self.send_message_to_user(uid, report.report_design_text, {}, false, true, 'search_result') if report.report_design_field_value('use_text_message') response = self.send_message_to_user(uid, '', { 'type' => 'image', 'mediaUrl' => report.report_design_image_url }, false, true, 'search_result') if !report.report_design_field_value('use_text_message') && report.report_design_field_value('use_visual_card')