Merge branch 'develop' into feat/contacts-redesign
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
|
||||
|
||||
@@ -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