Merge branch 'develop' into feat/email-forwarding

This commit is contained in:
Sivin Varghese
2025-05-06 08:33:13 +05:30
committed by GitHub
6 changed files with 50 additions and 18 deletions
@@ -2,10 +2,15 @@ class Api::V1::Widget::CampaignsController < Api::V1::Widget::BaseController
skip_before_action :set_contact
def index
@campaigns = @web_widget
.inbox
.campaigns
.where(enabled: true, account_id: @web_widget.inbox.account_id)
.includes(:sender)
account = @web_widget.inbox.account
@campaigns = if account.feature_enabled?('campaigns')
@web_widget
.inbox
.campaigns
.where(enabled: true, account_id: account.id)
.includes(:sender)
else
[]
end
end
end
@@ -65,7 +65,7 @@ watch(() => props.messages.length, scrollToBottom);
class="max-w-[80%] rounded-lg p-3 text-sm"
:class="getMessageStyle(message.sender)"
>
<div v-html="formatMessage(message.content)" />
<div class="break-words" v-html="formatMessage(message.content)" />
</div>
</div>
</div>
@@ -214,7 +214,7 @@ watch(
v-model="state.instructions"
:placeholder="t('CAPTAIN.ASSISTANTS.FORM.INSTRUCTIONS.PLACEHOLDER')"
:message="formErrors.instructions"
:max-length="2000"
:max-length="20000"
:message-type="formErrors.instructions ? 'error' : 'info'"
/>
@@ -394,23 +394,29 @@ function handleReplyTo() {
}
const avatarInfo = computed(() => {
if (!props.sender || props.sender.type === SENDER_TYPES.AGENT_BOT) {
// If no sender, return bot info
if (!props.sender) {
return {
name: t('CONVERSATION.BOT'),
src: '',
};
}
if (props.sender) {
const { sender } = props;
const { name, type, avatarUrl, thumbnail } = sender || {};
// If sender type is agent bot, use avatarUrl
if (type === SENDER_TYPES.AGENT_BOT) {
return {
name: props.sender.name,
src: props.sender?.thumbnail,
name: name ?? '',
src: avatarUrl ?? '',
};
}
// For all other senders, use thumbnail
return {
name: '',
src: '',
name: name ?? '',
src: thumbnail ?? '',
};
});
@@ -403,15 +403,18 @@
},
"NAME": {
"LABEL": "Name",
"PLACEHOLDER": "Enter assistant name"
"PLACEHOLDER": "Enter assistant name",
"ERROR": "The name is required"
},
"DESCRIPTION": {
"LABEL": "Description",
"PLACEHOLDER": "Enter assistant description"
"PLACEHOLDER": "Enter assistant description",
"ERROR": "The description is required"
},
"PRODUCT_NAME": {
"LABEL": "Product Name",
"PLACEHOLDER": "Enter product name"
"PLACEHOLDER": "Enter product name",
"ERROR": "The product name is required"
},
"WELCOME_MESSAGE": {
"LABEL": "Welcome Message",
@@ -9,7 +9,11 @@ RSpec.describe '/api/v1/widget/campaigns', type: :request do
describe 'GET /api/v1/widget/campaigns' do
let(:params) { { website_token: web_widget.website_token } }
context 'with correct website token' do
context 'when campaigns feature is enabled' do
before do
account.enable_features!('campaigns')
end
it 'returns the list of enabled campaigns' do
get '/api/v1/widget/campaigns', params: params
@@ -21,8 +25,22 @@ RSpec.describe '/api/v1/widget/campaigns', type: :request do
end
end
context 'when campaigns feature is disabled' do
before do
account.disable_features!('campaigns')
end
it 'returns empty array' do
get '/api/v1/widget/campaigns', params: params
expect(response).to have_http_status(:success)
json_response = response.parsed_body
expect(json_response).to eq []
end
end
context 'with invalid website token' do
it 'returns the list of agents' do
it 'returns not found status' do
get '/api/v1/widget/campaigns', params: { website_token: '' }
expect(response).to have_http_status(:not_found)
end