Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d708eedea | ||
|
|
c3e90d4cbc |
@@ -115,12 +115,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import format from 'date-fns/format';
|
||||
import { required, url } from 'vuelidate/lib/validators';
|
||||
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||
import MultiselectDropdown from 'shared/components/ui/MultiselectDropdown.vue';
|
||||
import { isValidURL } from '../helper/URLHelper';
|
||||
const DATE_FORMAT = 'yyyy-MM-dd';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -144,9 +142,6 @@ export default {
|
||||
|
||||
computed: {
|
||||
formattedValue() {
|
||||
if (this.isAttributeTypeDate) {
|
||||
return format(new Date(this.value || new Date()), DATE_FORMAT);
|
||||
}
|
||||
if (this.isAttributeTypeCheckbox) {
|
||||
return this.value === 'false' ? false : this.value;
|
||||
}
|
||||
@@ -193,8 +188,11 @@ export default {
|
||||
return this.$t('CUSTOM_ATTRIBUTES.VALIDATIONS.REQUIRED');
|
||||
},
|
||||
displayValue() {
|
||||
if (this.attributeType === 'date') {
|
||||
return format(new Date(this.editedValue), 'dd-MM-yyyy');
|
||||
if (this.attributeType === 'date' && this.editedValue) {
|
||||
return this.editedValue
|
||||
.split('-')
|
||||
.reverse()
|
||||
.join('-');
|
||||
}
|
||||
return this.editedValue;
|
||||
},
|
||||
@@ -247,17 +245,12 @@ export default {
|
||||
}
|
||||
},
|
||||
onUpdate() {
|
||||
const updatedValue =
|
||||
this.attributeType === 'date'
|
||||
? format(new Date(this.editedValue), DATE_FORMAT)
|
||||
: this.editedValue;
|
||||
|
||||
this.$v.$touch();
|
||||
if (this.$v.$invalid) {
|
||||
return;
|
||||
}
|
||||
this.isEditing = false;
|
||||
this.$emit('update', this.attributeKey, updatedValue);
|
||||
this.$emit('update', this.attributeKey, this.editedValue);
|
||||
},
|
||||
onDelete() {
|
||||
this.isEditing = false;
|
||||
|
||||
@@ -49,10 +49,6 @@ export class AnalyticsHelper {
|
||||
avatar: this.user.avatar_url,
|
||||
});
|
||||
|
||||
if (window.clarity) {
|
||||
window.clarity('identify', this.user.email);
|
||||
}
|
||||
|
||||
const { accounts, account_id: accountId } = this.user;
|
||||
const [currentAccount] = accounts.filter(
|
||||
account => account.id === accountId
|
||||
|
||||
@@ -35,9 +35,9 @@ class Imap::ImapMailbox
|
||||
end
|
||||
|
||||
def find_conversation_by_in_reply_to
|
||||
return if in_reply_to.blank? && @inbound_mail.references.blank?
|
||||
return if in_reply_to.blank?
|
||||
|
||||
message = @inbox.messages.find_by(source_id: in_reply_to) || find_message_by_references
|
||||
message = @inbox.messages.find_by(source_id: in_reply_to)
|
||||
if message.nil?
|
||||
@inbox.conversations.where("additional_attributes->>'in_reply_to' = ?", in_reply_to).first
|
||||
else
|
||||
@@ -49,20 +49,6 @@ class Imap::ImapMailbox
|
||||
@inbound_mail.in_reply_to
|
||||
end
|
||||
|
||||
def find_message_by_references
|
||||
message_to_return = nil
|
||||
|
||||
return if @inbound_mail.references.blank?
|
||||
|
||||
references = @inbound_mail.references
|
||||
|
||||
references.each do |message_id|
|
||||
message = @inbox.messages.find_by(source_id: message_id)
|
||||
message_to_return = message if message.present?
|
||||
end
|
||||
message_to_return
|
||||
end
|
||||
|
||||
def find_or_create_conversation
|
||||
@conversation = find_conversation_by_in_reply_to || ::Conversation.create!({ account_id: @account.id,
|
||||
inbox_id: @inbox.id,
|
||||
|
||||
@@ -28,7 +28,6 @@ class AgentBot < ApplicationRecord
|
||||
enum bot_type: { webhook: 0, csml: 1 }
|
||||
|
||||
validate :validate_agent_bot_config
|
||||
validates :outgoing_url, length: { maximum: Limits::URL_LENGTH_LIMIT }
|
||||
|
||||
def available_name
|
||||
name
|
||||
|
||||
@@ -37,7 +37,7 @@ class Attachment < ApplicationRecord
|
||||
belongs_to :message
|
||||
has_one_attached :file
|
||||
validate :acceptable_file
|
||||
validates :external_url, length: { maximum: Limits::URL_LENGTH_LIMIT }
|
||||
validates :external_url, length: { maximum: 1000 }
|
||||
enum file_type: [:image, :audio, :video, :file, :location, :fallback, :share, :story_mention, :contact]
|
||||
|
||||
def push_event_data
|
||||
|
||||
@@ -27,7 +27,6 @@ class Channel::Api < ApplicationRecord
|
||||
has_secure_token :identifier
|
||||
has_secure_token :hmac_token
|
||||
validate :ensure_valid_agent_reply_time_window
|
||||
validates :webhook_url, length: { maximum: Limits::URL_LENGTH_LIMIT }
|
||||
|
||||
def name
|
||||
'API'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
module Limits
|
||||
BULK_ACTIONS_LIMIT = 100
|
||||
BULK_EXTERNAL_HTTP_CALLS_LIMIT = 25
|
||||
URL_LENGTH_LIMIT = 2048 # https://stackoverflow.com/questions/417142
|
||||
end
|
||||
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
From: Sony Mathew <sony@chatwoot.com>
|
||||
Mime-Version: 1.0 (Apple Message framework v1244.3)
|
||||
Content-Type: multipart/alternative; boundary="Apple-Mail=_33A037C7-4BB3-4772-AE52-FCF2D7535F74"
|
||||
Subject: Discussion: Let's debate these attachments
|
||||
Date: Tue, 20 Apr 2020 04:20:20 -0400
|
||||
In-Reply-To: <4e6e35f5a38b4_479f13bb90078178@small-app-01.mail>
|
||||
References: <4e6e35f5a38b4_479f13bb90078178@small-app-01.mail> <test-reference-id>
|
||||
Message-Id: <0CB459E0-0336-41DA-BC88-E6E28C697DDBF@chatwoot.com>
|
||||
X-Mailer: Apple Mail (2.1244.3)
|
||||
|
||||
--Apple-Mail=_33A037C7-4BB3-4772-AE52-FCF2D7535F74
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-Type: text/plain;
|
||||
charset=utf-8
|
||||
|
||||
References Email
|
||||
@@ -83,34 +83,11 @@ RSpec.describe Imap::ImapMailbox do
|
||||
let(:reply_mail) do
|
||||
create_inbound_email_from_mail(from: 'email@gmail.com', to: 'imap@gmail.com', subject: 'Hello!', in_reply_to: 'test-in-reply-to')
|
||||
end
|
||||
let(:references_email) { create_inbound_email_from_fixture('references.eml') }
|
||||
|
||||
it 'creates new email conversation with incoming in-reply-to' do
|
||||
class_instance.process(reply_mail.mail, channel)
|
||||
expect(conversation.additional_attributes['in_reply_to']).to eq(reply_mail.mail.in_reply_to)
|
||||
end
|
||||
|
||||
it 'append email to conversation with references id' do
|
||||
inbox = Inbox.last
|
||||
message = create(
|
||||
:message,
|
||||
content: 'Incoming Message',
|
||||
message_type: 'incoming',
|
||||
inbox: inbox,
|
||||
source_id: 'test-reference-id',
|
||||
account: account,
|
||||
conversation: conversation
|
||||
)
|
||||
conversation = message.conversation
|
||||
|
||||
expect(conversation.messages.size).to eq(1)
|
||||
|
||||
class_instance.process(references_email.mail, inbox.channel)
|
||||
|
||||
expect(conversation.messages.size).to eq(2)
|
||||
expect(conversation.messages.last.content).to eq('References Email')
|
||||
expect(references_email.mail.references).to include('test-reference-id')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,19 +12,4 @@ RSpec.describe AgentBot do
|
||||
it_behaves_like 'access_tokenable'
|
||||
it_behaves_like 'avatarable'
|
||||
end
|
||||
|
||||
context 'when it validates outgoing_url length' do
|
||||
let(:agent_bot) { create(:agent_bot) }
|
||||
|
||||
it 'valid when within limit' do
|
||||
agent_bot.outgoing_url = 'a' * Limits::URL_LENGTH_LIMIT
|
||||
expect(agent_bot.valid?).to be true
|
||||
end
|
||||
|
||||
it 'invalid when crossed the limit' do
|
||||
agent_bot.outgoing_url = 'a' * (Limits::URL_LENGTH_LIMIT + 1)
|
||||
agent_bot.valid?
|
||||
expect(agent_bot.errors[:outgoing_url]).to include("is too long (maximum is #{Limits::URL_LENGTH_LIMIT} characters)")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,14 +11,14 @@ RSpec.describe Attachment do
|
||||
|
||||
context 'when it validates external url length' do
|
||||
it 'valid when within limit' do
|
||||
attachment.external_url = 'a' * Limits::URL_LENGTH_LIMIT
|
||||
attachment.external_url = 'a' * 1000
|
||||
expect(attachment.valid?).to be true
|
||||
end
|
||||
|
||||
it 'invalid when crossed the limit' do
|
||||
attachment.external_url = 'a' * (Limits::URL_LENGTH_LIMIT + 5)
|
||||
attachment.external_url = 'a' * 1500
|
||||
attachment.valid?
|
||||
expect(attachment.errors[:external_url]).to include("is too long (maximum is #{Limits::URL_LENGTH_LIMIT} characters)")
|
||||
expect(attachment.errors[:external_url]).to include('is too long (maximum is 1000 characters)')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Channel::Api do
|
||||
# This validation happens in ApplicationRecord
|
||||
describe 'length validations' do
|
||||
let(:channel_api) { create(:channel_api) }
|
||||
|
||||
context 'when it validates webhook_url length' do
|
||||
it 'valid when within limit' do
|
||||
channel_api.webhook_url = 'a' * Limits::URL_LENGTH_LIMIT
|
||||
expect(channel_api.valid?).to be true
|
||||
end
|
||||
|
||||
it 'invalid when crossed the limit' do
|
||||
channel_api.webhook_url = 'a' * (Limits::URL_LENGTH_LIMIT + 1)
|
||||
channel_api.valid?
|
||||
expect(channel_api.errors[:webhook_url]).to include("is too long (maximum is #{Limits::URL_LENGTH_LIMIT} characters)")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user