entry.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. "time"
  6. )
  7. // Entry statuses and default sorting order.
  8. const (
  9. EntryStatusUnread = "unread"
  10. EntryStatusRead = "read"
  11. EntryStatusRemoved = "removed"
  12. DefaultSortingOrder = "published_at"
  13. DefaultSortingDirection = "asc"
  14. )
  15. // Entry represents a feed item in the system.
  16. type Entry struct {
  17. ID int64 `json:"id"`
  18. UserID int64 `json:"user_id"`
  19. FeedID int64 `json:"feed_id"`
  20. Status string `json:"status"`
  21. Hash string `json:"hash"`
  22. Title string `json:"title"`
  23. URL string `json:"url"`
  24. CommentsURL string `json:"comments_url"`
  25. Date time.Time `json:"published_at"`
  26. CreatedAt time.Time `json:"created_at"`
  27. ChangedAt time.Time `json:"changed_at"`
  28. Content string `json:"content"`
  29. Author string `json:"author"`
  30. ShareCode string `json:"share_code"`
  31. Starred bool `json:"starred"`
  32. ReadingTime int `json:"reading_time"`
  33. Enclosures EnclosureList `json:"enclosures"`
  34. Feed *Feed `json:"feed,omitempty"`
  35. Tags []string `json:"tags"`
  36. }
  37. func NewEntry() *Entry {
  38. return &Entry{
  39. Enclosures: make(EnclosureList, 0),
  40. Tags: make([]string, 0),
  41. Feed: &Feed{
  42. Category: &Category{},
  43. Icon: &FeedIcon{},
  44. },
  45. }
  46. }
  47. // Entries represents a list of entries.
  48. type Entries []*Entry
  49. // EntriesStatusUpdateRequest represents a request to change entries status.
  50. type EntriesStatusUpdateRequest struct {
  51. EntryIDs []int64 `json:"entry_ids"`
  52. Status string `json:"status"`
  53. }
  54. // EntryUpdateRequest represents a request to update an entry.
  55. type EntryUpdateRequest struct {
  56. Title *string `json:"title"`
  57. Content *string `json:"content"`
  58. }
  59. func (e *EntryUpdateRequest) Patch(entry *Entry) {
  60. if e.Title != nil && *e.Title != "" {
  61. entry.Title = *e.Title
  62. }
  63. if e.Content != nil && *e.Content != "" {
  64. entry.Content = *e.Content
  65. }
  66. }