Merge branch 'feat/contacts-redesign' into feat/compose-new-conversation
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="absolute">
|
||||
<ul
|
||||
class="text-sm bg-n-solid-1 border border-n-weak rounded-xl shadow-sm py-2 n-dropdown-body gap-2 grid list-none px-2 reset-base"
|
||||
class="text-sm bg-n-alpha-3 backdrop-blur-[100px] border border-n-weak rounded-xl shadow-sm py-2 n-dropdown-body gap-2 grid list-none px-2 reset-base"
|
||||
>
|
||||
<slot />
|
||||
</ul>
|
||||
|
||||
@@ -39,7 +39,7 @@ const triggerClick = () => {
|
||||
v-bind="$attrs"
|
||||
class="flex text-left rtl:text-right items-center p-2 reset-base text-sm text-n-slate-12 w-full border-0"
|
||||
:class="{
|
||||
'hover:bg-n-alpha-1 rounded-lg w-full gap-3': !$slots.default,
|
||||
'hover:bg-n-alpha-2 rounded-lg w-full gap-3': !$slots.default,
|
||||
}"
|
||||
:href="props.link || null"
|
||||
@click="triggerClick"
|
||||
|
||||
@@ -8,8 +8,21 @@ class Avatar::AvatarFromUrlJob < ApplicationJob
|
||||
avatar_url,
|
||||
max_size: 15 * 1024 * 1024
|
||||
)
|
||||
avatarable.avatar.attach(io: avatar_file, filename: avatar_file.original_filename, content_type: avatar_file.content_type)
|
||||
if valid_image?(avatar_file)
|
||||
avatarable.avatar.attach(io: avatar_file, filename: avatar_file.original_filename,
|
||||
content_type: avatar_file.content_type)
|
||||
end
|
||||
rescue Down::NotFound, Down::Error => e
|
||||
Rails.logger.error "Exception: invalid avatar url #{avatar_url} : #{e.message}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_image?(file)
|
||||
return false if file.original_filename.blank?
|
||||
|
||||
# TODO: check if the file is an actual image
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
Generated
+8
-7
@@ -1885,6 +1885,7 @@ packages:
|
||||
'@xmldom/xmldom@0.7.13':
|
||||
resolution: {integrity: sha512-lm2GW5PkosIzccsaZIz7tp8cPADSIlIHWDFTR1N0SzfinhhYgeIQjFMz4rYzanCScr3DqQLeomUDArp6MWKm+g==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
deprecated: this version is no longer supported, please update to at least 0.8.*
|
||||
|
||||
abab@2.0.6:
|
||||
resolution: {integrity: sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==}
|
||||
@@ -2283,8 +2284,8 @@ packages:
|
||||
crelt@1.0.5:
|
||||
resolution: {integrity: sha512-+BO9wPPi+DWTDcNYhr/W90myha8ptzftZT+LwcmUbbok0rcP/fequmFYCw8NMoH7pkAZQzU78b3kYrlua5a9eA==}
|
||||
|
||||
cross-spawn@7.0.3:
|
||||
resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==}
|
||||
cross-spawn@7.0.6:
|
||||
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
crypt@0.0.2:
|
||||
@@ -7382,7 +7383,7 @@ snapshots:
|
||||
|
||||
crelt@1.0.5: {}
|
||||
|
||||
cross-spawn@7.0.3:
|
||||
cross-spawn@7.0.6:
|
||||
dependencies:
|
||||
path-key: 3.1.1
|
||||
shebang-command: 2.0.0
|
||||
@@ -7893,7 +7894,7 @@ snapshots:
|
||||
'@ungap/structured-clone': 1.2.0
|
||||
ajv: 6.12.6
|
||||
chalk: 4.1.2
|
||||
cross-spawn: 7.0.3
|
||||
cross-spawn: 7.0.6
|
||||
debug: 4.3.5
|
||||
doctrine: 3.0.0
|
||||
escape-string-regexp: 4.0.0
|
||||
@@ -7954,7 +7955,7 @@ snapshots:
|
||||
|
||||
execa@7.2.0:
|
||||
dependencies:
|
||||
cross-spawn: 7.0.3
|
||||
cross-spawn: 7.0.6
|
||||
get-stream: 6.0.1
|
||||
human-signals: 4.3.1
|
||||
is-stream: 3.0.0
|
||||
@@ -7966,7 +7967,7 @@ snapshots:
|
||||
|
||||
execa@8.0.1:
|
||||
dependencies:
|
||||
cross-spawn: 7.0.3
|
||||
cross-spawn: 7.0.6
|
||||
get-stream: 8.0.1
|
||||
human-signals: 5.0.0
|
||||
is-stream: 3.0.0
|
||||
@@ -8063,7 +8064,7 @@ snapshots:
|
||||
|
||||
foreground-child@3.3.0:
|
||||
dependencies:
|
||||
cross-spawn: 7.0.3
|
||||
cross-spawn: 7.0.6
|
||||
signal-exit: 4.1.0
|
||||
|
||||
form-data@4.0.0:
|
||||
|
||||
@@ -17,4 +17,20 @@ RSpec.describe Avatar::AvatarFromUrlJob do
|
||||
described_class.perform_now(avatarable, avatar_url)
|
||||
expect(avatarable.avatar).to be_attached
|
||||
end
|
||||
|
||||
# ref: https://github.com/chatwoot/chatwoot/issues/10449
|
||||
it 'will not throw error if the avatar url is not valid and the file does not have a filename' do
|
||||
# Create a temporary file with no filename and content type application/xml
|
||||
temp_file = Tempfile.new(['invalid', '.xml'])
|
||||
temp_file.write('<invalid>content</invalid>')
|
||||
temp_file.rewind
|
||||
|
||||
expect(Down).to receive(:download).with(avatar_url, max_size: 15 * 1024 * 1024)
|
||||
.and_return(ActionDispatch::Http::UploadedFile.new(tempfile: temp_file, type: 'application/xml'))
|
||||
|
||||
expect { described_class.perform_now(avatarable, avatar_url) }.not_to raise_error
|
||||
|
||||
temp_file.close
|
||||
temp_file.unlink # deletes the temp file
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user