Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RELEASE 2024-03-08 #128

Merged
merged 9 commits into from
Mar 11, 2024
7 changes: 5 additions & 2 deletions app/controllers/widgets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ def set_web_widget

def check_domain
return if Rails.env.development?
return if request.headers['Referer'].downcase.start_with? @web_widget.website_url.downcase

# support multiple domains from same referer header param
domains = @web_widget.website_url.downcase.split("|")
domains.each do |domain|
return if request.headers['Referer'].downcase.start_with? domain
end
Rails.logger.error('web widget does not match with expected domain')
render json: { error: 'web widget does not match with expected domain' }, status: :not_found
end
Expand Down
5 changes: 4 additions & 1 deletion app/javascript/widget/components/AgentMessageBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ export default {
setCallback: 'conversation/setQuickRepliesCallback',
}),
async onOptionSelect(selectedOption) {
await this.$store.dispatch('message/update', {
submittedValues: [selectedOption],
messageId: this.messageId,
});
this.setOptions([]);
await this.sendMessage({content: selectedOption.title});
// Scroll to bottom once the quick reply is clicked
const container = document.getElementById('conversation-container');
container.scrollTo(0, container.scrollHeight);
Expand Down
1 change: 0 additions & 1 deletion app/javascript/widget/components/ChatFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export default {
startNewConversation() {
this.clearConversations();
this.clearConversationAttributes();
this.replaceRoute('prechat-form');
},
async sendTranscript() {
const { email } = this.currentUser;
Expand Down
10 changes: 6 additions & 4 deletions app/javascript/widget/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<script>
import configMixin from '../mixins/configMixin';
import TeamAvailability from 'widget/components/TeamAvailability';
import { mapGetters } from 'vuex';
import { mapGetters, mapActions } from 'vuex';
import routerMixin from 'widget/mixins/routerMixin';
export default {
name: 'Home',
Expand Down Expand Up @@ -43,12 +43,14 @@ export default {
}),
},
methods: {
...mapActions('conversation', [
'clearConversations',
]),
startConversation() {
const ref = new URLSearchParams(window.location.search).get('referral');
if (ref) {
this.$store.dispatch('conversation/createConversation', {});
}
if (this.preChatFormEnabled && !this.conversationSize) {
this.clearConversations();
} else if (this.preChatFormEnabled && !this.conversationSize) {
return this.replaceRoute('prechat-form');
}
return this.replaceRoute('messages');
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/widgets_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

describe 'GET /widget' do
it 'renders the page correctly when called with website_token' do
Rails.env = 'development'
get widget_url(website_token: web_widget.website_token)
expect(response).to be_successful
expect(response.body).not_to include(token)
end

it 'renders the page correctly when called with website_token and cw_conversation' do
Rails.env = 'development'
get widget_url(website_token: web_widget.website_token, cw_conversation: token)
expect(response).to be_successful
expect(response.body).to include(token)
Expand Down
Loading