From 66003dac217f3d523da258ccb1e651cb3044aa08 Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Tue, 26 Feb 2019 11:55:08 +0000 Subject: [PATCH] Logo fetching to match on domain mismatch Fixes #209 Sometimes people use subdomain like docs.example.org but backend does not reflect the domain, e.g. dmz_org.c_domain is empty. So we fall back to loading logo for empty c_domain value as well. --- domain/meta/endpoint.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/domain/meta/endpoint.go b/domain/meta/endpoint.go index 5aea9328..65796a8e 100644 --- a/domain/meta/endpoint.go +++ b/domain/meta/endpoint.go @@ -310,12 +310,20 @@ func (h *Handler) Logo(w http.ResponseWriter, r *http.Request) { ctx := domain.GetRequestContext(r) d := organization.GetSubdomainFromHost(r) - // If organization has logo, send it back. + // If organization has logo, send it back by using specified subdomain. logo, err := h.Store.Organization.Logo(ctx, d) if err == nil && len(logo) > 0 { h.writeLogo(w, r, logo) return } + + // Sometimes people use subdomain like docs.example.org but backend + // does not reflect that domain, e.g. dmz_org.c_domain is empty. + logo, err = h.Store.Organization.Logo(ctx, "") + if err == nil && len(logo) > 0 { + h.writeLogo(w, r, logo) + return + } if err != nil { h.Runtime.Log.Infof("unable to fetch logo for domain %s", d) }