mirror of
https://github.com/chatwoot/chatwoot.git
synced 2026-06-04 21:02:35 +08:00
Merge branch 'develop' into codex/fix-imap-contact-name-truncation
This commit is contained in:
commit
473f2de2ea
@ -6,8 +6,7 @@ class Api::V1::Accounts::Microsoft::AuthorizationsController < Api::V1::Accounts
|
||||
{
|
||||
redirect_uri: "#{base_url}/microsoft/callback",
|
||||
scope: scope,
|
||||
state: state,
|
||||
prompt: 'consent'
|
||||
state: state
|
||||
}
|
||||
)
|
||||
if redirect_url
|
||||
|
||||
@ -147,7 +147,7 @@ class Whatsapp::IncomingMessageBaseService
|
||||
|
||||
def attach_location
|
||||
location = messages_data.first['location']
|
||||
location_name = location['name'] ? "#{location['name']}, #{location['address']}" : ''
|
||||
location_name = (location['name'] ? "#{location['name']}, #{location['address']}" : '').first(255)
|
||||
@message.attachments.new(
|
||||
account_id: @message.account_id,
|
||||
file_type: file_content_type(message_type),
|
||||
|
||||
@ -43,6 +43,7 @@ RSpec.describe 'Microsoft Authorization API', type: :request do
|
||||
]
|
||||
expect(params['scope']).to eq(expected_scope)
|
||||
expect(params['redirect_uri']).to eq(["#{ENV.fetch('FRONTEND_URL', 'http://localhost:3000')}/microsoft/callback"])
|
||||
expect(url).not_to match(/(?:\?|&)prompt=/)
|
||||
|
||||
# Validate state parameter exists and can be decoded back to the account
|
||||
expect(params['state']).to be_present
|
||||
|
||||
@ -381,6 +381,32 @@ describe Whatsapp::IncomingMessageService do
|
||||
expect(location_attachment.coordinates_long).to eq(-122.3895553)
|
||||
expect(location_attachment.external_url).to eq('http://location_url.test')
|
||||
end
|
||||
|
||||
it 'truncates long fallback titles to avoid dropping location messages' do
|
||||
long_place_name = [
|
||||
'Gremi de Fusters, 33, Edificio VIP Asima, Piso 2, Local 2, Norte',
|
||||
'07009 Poligon industrial de Son Castello, Illes Balears, Espana'
|
||||
].join(', ')
|
||||
source_id = 'wamid.long-location-fallback-title'
|
||||
params = {
|
||||
'contacts' => [{ 'profile' => { 'name' => 'Sojan Jose' }, 'wa_id' => '2423423243' }],
|
||||
'messages' => [{ 'from' => '2423423243', 'id' => source_id,
|
||||
'location' => { 'id' => 'b1c68f38-8734-4ad3-b4a1-ef0c10d683',
|
||||
:address => long_place_name,
|
||||
:latitude => 37.7893768,
|
||||
:longitude => -122.3895553,
|
||||
:name => long_place_name,
|
||||
:url => 'http://location_url.test' },
|
||||
'timestamp' => '1633034394', 'type' => 'location' }]
|
||||
}.with_indifferent_access
|
||||
|
||||
expect { described_class.new(inbox: whatsapp_channel.inbox, params: params).perform }
|
||||
.to change { Message.where(source_id: source_id).count }.from(0).to(1)
|
||||
|
||||
location_attachment = Message.find_by!(source_id: source_id).attachments.first
|
||||
expect(location_attachment.fallback_title).to eq("#{long_place_name}, #{long_place_name}".first(255))
|
||||
expect(location_attachment.fallback_title.length).to eq(255)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when valid contact message params' do
|
||||
|
||||
Loading…
Reference in New Issue
Block a user