icon.go 876 B

1234567891011121314151617181920212223242526272829303132
  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. )
  7. // Icon represents a website icon (favicon)
  8. type Icon struct {
  9. ID int64 `json:"id"`
  10. Hash string `json:"hash"`
  11. MimeType string `json:"mime_type"`
  12. Content []byte `json:"-"`
  13. ExternalID string `json:"external_id"`
  14. }
  15. // DataURL returns the data URL of the icon.
  16. func (i *Icon) DataURL() string {
  17. return i.MimeType + ";base64," + base64.StdEncoding.EncodeToString(i.Content)
  18. }
  19. // Icons represents a list of icons.
  20. type Icons []*Icon
  21. // FeedIcon is a junction table between feeds and icons.
  22. type FeedIcon struct {
  23. FeedID int64 `json:"feed_id"`
  24. IconID int64 `json:"icon_id"`
  25. ExternalIconID string `json:"external_icon_id"`
  26. }