icon.go 783 B

12345678910111213141516171819202122232425262728293031
  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. }
  15. // DataURL returns the data URL of the icon.
  16. func (i *Icon) DataURL() string {
  17. return fmt.Sprintf("%s;base64,%s", i.MimeType, 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. }