From 736b4137cc2cb5f725a9d1a7a8e93652ee5cdc8a Mon Sep 17 00:00:00 2001 From: romanrizzi Date: Sun, 31 Jan 2021 22:35:41 -0300 Subject: [PATCH] FIX: Return the CDN's URL when using the site's small logo as the system's user avatar. Using "UrlHelper#absolute" returns the S3 URL, which is fine for the client because it modifies it to use the CDN instead. On the other hand, this replacement doesn't happen when the URL is server-side rendered, returning a 403 for the system's avatar. --- app/models/user.rb | 2 +- spec/models/user_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 315eac92d8..c33b5f99a0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -873,7 +873,7 @@ class User < ActiveRecord::Base SiteSetting.logo_small && SiteSetting.use_site_small_logo_as_system_avatar if use_small_logo - UrlHelper.absolute(SiteSetting.logo_small.url) + Discourse.store.cdn_url(SiteSetting.logo_small.url) else self.class.avatar_template(username, uploaded_avatar_id) end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 33bd7b5773..c6abcb33f3 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1339,7 +1339,7 @@ describe User do describe '#avatar_template' do it 'uses the small logo if the user is the system user' do - logo_small_url = UrlHelper.absolute(SiteSetting.logo_small.url) + logo_small_url = Discourse.store.cdn_url(SiteSetting.logo_small.url) expect(Discourse.system_user.avatar_template).to eq(logo_small_url) end