icon.go 898 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package model // import "miniflux.app/v2/internal/model"
  4. import (
  5. "encoding/base64"
  6. "fmt"
  7. )
  8. // Icon represents a website icon (favicon)
  9. type Icon struct {
  10. ID int64 `json:"id"`
  11. Hash string `json:"hash"`
  12. MimeType string `json:"mime_type"`
  13. Content []byte `json:"-"`
  14. ExternalID string `json:"external_id"`
  15. }
  16. // DataURL returns the data URL of the icon.
  17. func (i *Icon) DataURL() string {
  18. return fmt.Sprintf("%s;base64,%s", i.MimeType, base64.StdEncoding.EncodeToString(i.Content))
  19. }
  20. // Icons represents a list of icons.
  21. type Icons []*Icon
  22. // FeedIcon is a junction table between feeds and icons.
  23. type FeedIcon struct {
  24. FeedID int64 `json:"feed_id"`
  25. IconID int64 `json:"icon_id"`
  26. ExternalIconID string `json:"external_icon_id"`
  27. }