From d86cb7d1c3b1cc5e51b398f0c39ac1f3faa5b0ae Mon Sep 17 00:00:00 2001
From: Rafael dos Santos Silva <xfalcox@gmail.com>
Date: Thu, 18 Feb 2021 17:24:44 -0300
Subject: [PATCH] FIX: Use the S3 CDN for the Group flair (#12130)

---
 app/models/group.rb | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/app/models/group.rb b/app/models/group.rb
index 82679309051..5f752afb030 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -12,6 +12,7 @@ class Group < ActiveRecord::Base
   include HasCustomFields
   include AnonCacheInvalidator
   include HasDestroyedWebHook
+  include GlobalPath
 
   cattr_accessor :preloaded_custom_field_names
   self.preloaded_custom_field_names = Set.new
@@ -750,7 +751,14 @@ class Group < ActiveRecord::Base
   end
 
   def flair_url
-    flair_icon.presence || flair_upload&.url
+    case flair_type
+    when :icon
+      flair_icon
+    when :image
+      upload_cdn_path(flair_upload.url)
+    else
+      nil
+    end
   end
 
   [:muted, :regular, :tracking, :watching, :watching_first_post].each do |level|