fix: Disable enqueueing Avatar jobs if the URL is invalid (#12035)

- Add a new queue purgable
- Disable enqueuing the job if URL is invalid
This commit is contained in:
Pranav
2025-07-24 12:56:39 +04:00
committed by GitHub
parent 2a5ecf84a1
commit 9acb0d86b5
7 changed files with 21 additions and 6 deletions

View File

@@ -36,12 +36,18 @@ describe ContactIdentifyAction do
expect(result.additional_attributes['social_profiles']).to eq({ 'linkedin' => 'saras', 'twitter' => 'saras' })
end
it 'enques avatar job when avatar url parameter is passed' do
it 'enqueues avatar job when valid avatar url parameter is passed' do
params = { name: 'test', avatar_url: 'https://chatwoot-assets.local/sample.png' }
expect(Avatar::AvatarFromUrlJob).to receive(:perform_later).with(contact, params[:avatar_url]).once
described_class.new(contact: contact, params: params).perform
end
it 'does not enqueue avatar job when invalid avatar url parameter is passed' do
params = { name: 'test', avatar_url: 'invalid-url' }
expect(Avatar::AvatarFromUrlJob).not_to receive(:perform_later)
described_class.new(contact: contact, params: params).perform
end
context 'when contact with same identifier exists' do
it 'merges the current contact to identified contact' do
existing_identified_contact = create(:contact, account: account, identifier: 'test_id')