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:
26
pkg/thirdparty/service.go
vendored
26
pkg/thirdparty/service.go
vendored
@@ -17,17 +17,37 @@ package thirdparty
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/file"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
pg *pg.Client
|
||||
pg *pg.Client
|
||||
file *file.Service
|
||||
}
|
||||
|
||||
func NewService(pgClient *pg.Client) *Service {
|
||||
return &Service{pg: pgClient}
|
||||
func NewService(pgClient *pg.Client, fileSvc *file.Service) *Service {
|
||||
return &Service{
|
||||
pg: pgClient,
|
||||
file: fileSvc,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) GenerateLogoURL(
|
||||
ctx context.Context,
|
||||
logoFileID gid.GID,
|
||||
expiresIn time.Duration,
|
||||
) (*string, error) {
|
||||
url, err := s.file.GetPublicFileURL(ctx, logoFileID, expiresIn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot generate logo URL: %w", err)
|
||||
}
|
||||
|
||||
return &url, nil
|
||||
}
|
||||
|
||||
func (s *Service) Search(ctx context.Context, name string) ([]*coredata.CommonThirdParty, error) {
|
||||
|
||||
Reference in New Issue
Block a user