diff --git a/.env.example b/.env.example index efee18735..a97679f7e 100644 --- a/.env.example +++ b/.env.example @@ -199,7 +199,7 @@ ANDROID_SHA256_CERT_FINGERPRINT=AC:73:8E:DE:EB:56:EA:CC:10:87:02:A7:65:37:7B:38: ## Rack Attack configuration ## To prevent and throttle abusive requests # ENABLE_RACK_ATTACK=true -# RACK_ATTACK_IP_LIMIT=3000 +# RACK_ATTACK_LIMIT=300 # ENABLE_RACK_ATTACK_WIDGET_API=true ## Running chatwoot as an API only server diff --git a/app/controllers/public/api/v1/inboxes/conversations_controller.rb b/app/controllers/public/api/v1/inboxes/conversations_controller.rb index 3d86ca87c..c79952372 100644 --- a/app/controllers/public/api/v1/inboxes/conversations_controller.rb +++ b/app/controllers/public/api/v1/inboxes/conversations_controller.rb @@ -33,7 +33,7 @@ class Public::Api::V1::Inboxes::ConversationsController < Public::Api::V1::Inbox end def create_conversation - ::Conversation.create!(conversation_params) + ConversationBuilder.new(params: conversation_params, contact_inbox: @contact_inbox).perform end def trigger_typing_event(event) @@ -41,11 +41,6 @@ class Public::Api::V1::Inboxes::ConversationsController < Public::Api::V1::Inbox end def conversation_params - { - account_id: @contact_inbox.contact.account_id, - inbox_id: @contact_inbox.inbox_id, - contact_id: @contact_inbox.contact_id, - contact_inbox_id: @contact_inbox.id - } + params.permit(custom_attributes: {}) end end diff --git a/app/controllers/public/api/v1/portals/base_controller.rb b/app/controllers/public/api/v1/portals/base_controller.rb index 68619baf8..d9fec27b1 100644 --- a/app/controllers/public/api/v1/portals/base_controller.rb +++ b/app/controllers/public/api/v1/portals/base_controller.rb @@ -1,5 +1,6 @@ class Public::Api::V1::Portals::BaseController < PublicController before_action :show_plain_layout + before_action :set_color_scheme around_action :set_locale after_action :allow_iframe_requests @@ -9,6 +10,14 @@ class Public::Api::V1::Portals::BaseController < PublicController @is_plain_layout_enabled = params[:show_plain_layout] == 'true' end + def set_color_scheme + @theme = if %w[dark light].include?(params[:theme]) + params[:theme] + else + '' + end + end + def set_locale(&) switch_locale_with_portal(&) if params[:locale].present? switch_locale_with_article(&) if params[:article_slug].present? diff --git a/app/helpers/portal_helper.rb b/app/helpers/portal_helper.rb new file mode 100644 index 000000000..3551b5ac6 --- /dev/null +++ b/app/helpers/portal_helper.rb @@ -0,0 +1,11 @@ +module PortalHelper + def generate_portal_bg_color(portal_color, theme) + base_color = theme == 'dark' ? 'black' : 'white' + "color-mix(in srgb, #{portal_color} 10%, #{base_color})" + end + + def generate_portal_bg(portal_color, theme) + bg_image = theme == 'dark' ? 'grid_dark.svg' : 'grid.svg' + "background: url(/assets/images/hc/#{bg_image}) #{generate_portal_bg_color(portal_color, theme)}" + end +end diff --git a/app/javascript/portal/components/PublicSearchInput.vue b/app/javascript/portal/components/PublicSearchInput.vue index a1b36fd66..53099a08e 100644 --- a/app/javascript/portal/components/PublicSearchInput.vue +++ b/app/javascript/portal/components/PublicSearchInput.vue @@ -1,16 +1,16 @@