Self-host common third party logos via S3

Fetch favicons at import time instead of calling Google's favicon
service per page load. Logos are stored as public files in S3 and
served through the existing /api/files/v1/{id} endpoint.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-11 12:23:52 +04:00
parent 7099a3d702
commit 4a405ce16c
9 changed files with 338 additions and 8 deletions

View File

@@ -46,6 +46,7 @@ type (
TermsOfServiceURL *string `db:"terms_of_service_url"`
SecurityPageURL *string `db:"security_page_url"`
TrustPageURL *string `db:"trust_page_url"`
LogoFileID *gid.GID `db:"logo_file_id"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
@@ -78,6 +79,7 @@ SELECT
terms_of_service_url,
security_page_url,
trust_page_url,
logo_file_id,
created_at,
updated_at
FROM
@@ -133,6 +135,7 @@ SELECT
terms_of_service_url,
security_page_url,
trust_page_url,
logo_file_id,
created_at,
updated_at
FROM
@@ -187,6 +190,7 @@ INSERT INTO common_third_parties (
terms_of_service_url,
security_page_url,
trust_page_url,
logo_file_id,
created_at,
updated_at
) VALUES (
@@ -208,6 +212,7 @@ INSERT INTO common_third_parties (
@terms_of_service_url,
@security_page_url,
@trust_page_url,
@logo_file_id,
@created_at,
@updated_at
)
@@ -232,6 +237,7 @@ INSERT INTO common_third_parties (
"terms_of_service_url": t.TermsOfServiceURL,
"security_page_url": t.SecurityPageURL,
"trust_page_url": t.TrustPageURL,
"logo_file_id": t.LogoFileID,
"created_at": t.CreatedAt,
"updated_at": t.UpdatedAt,
}
@@ -271,6 +277,7 @@ INSERT INTO common_third_parties (
terms_of_service_url,
security_page_url,
trust_page_url,
logo_file_id,
created_at,
updated_at
) VALUES (
@@ -292,6 +299,7 @@ INSERT INTO common_third_parties (
@terms_of_service_url,
@security_page_url,
@trust_page_url,
@logo_file_id,
@created_at,
@updated_at
)
@@ -337,6 +345,7 @@ RETURNING (xmax = 0) AS inserted
"terms_of_service_url": t.TermsOfServiceURL,
"security_page_url": t.SecurityPageURL,
"trust_page_url": t.TrustPageURL,
"logo_file_id": t.LogoFileID,
"created_at": t.CreatedAt,
"updated_at": t.UpdatedAt,
}
@@ -401,6 +410,7 @@ SELECT
terms_of_service_url,
security_page_url,
trust_page_url,
logo_file_id,
created_at,
updated_at
FROM
@@ -430,3 +440,34 @@ LIMIT 20
return nil
}
func (t CommonThirdParty) UpdateLogoFileID(
ctx context.Context,
conn pg.Tx,
) error {
q := `
UPDATE common_third_parties
SET
logo_file_id = @logo_file_id,
updated_at = @updated_at
WHERE
id = @id
`
args := pgx.StrictNamedArgs{
"id": t.ID,
"logo_file_id": t.LogoFileID,
"updated_at": t.UpdatedAt,
}
result, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot update common third party logo: %w", err)
}
if result.RowsAffected() == 0 {
return ErrResourceNotFound
}
return nil
}

View File

@@ -0,0 +1,15 @@
-- Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
ALTER TABLE common_third_parties ADD COLUMN logo_file_id TEXT REFERENCES files(id);