miniflux.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the MIT license
  3. // that can be found in the LICENSE file.
  4. package miniflux
  5. import (
  6. "fmt"
  7. "time"
  8. )
  9. // Entry statuses.
  10. const (
  11. EntryStatusUnread = "unread"
  12. EntryStatusRead = "read"
  13. EntryStatusRemoved = "removed"
  14. )
  15. // User represents a user in the system.
  16. type User struct {
  17. ID int64 `json:"id"`
  18. Username string `json:"username"`
  19. Password string `json:"password,omitempty"`
  20. IsAdmin bool `json:"is_admin"`
  21. Theme string `json:"theme"`
  22. Language string `json:"language"`
  23. Timezone string `json:"timezone"`
  24. EntryDirection string `json:"entry_sorting_direction"`
  25. LastLoginAt *time.Time `json:"last_login_at"`
  26. Extra map[string]string `json:"extra"`
  27. }
  28. func (u User) String() string {
  29. return fmt.Sprintf("#%d - %s (admin=%v)", u.ID, u.Username, u.IsAdmin)
  30. }
  31. // UserModification is used to update a user.
  32. type UserModification struct {
  33. Username *string `json:"username"`
  34. Password *string `json:"password"`
  35. IsAdmin *bool `json:"is_admin"`
  36. Theme *string `json:"theme"`
  37. Language *string `json:"language"`
  38. Timezone *string `json:"timezone"`
  39. EntryDirection *string `json:"entry_sorting_direction"`
  40. }
  41. // Users represents a list of users.
  42. type Users []User
  43. // Category represents a category in the system.
  44. type Category struct {
  45. ID int64 `json:"id,omitempty"`
  46. Title string `json:"title,omitempty"`
  47. UserID int64 `json:"user_id,omitempty"`
  48. }
  49. func (c Category) String() string {
  50. return fmt.Sprintf("#%d %s", c.ID, c.Title)
  51. }
  52. // Categories represents a list of categories.
  53. type Categories []*Category
  54. // Subscription represents a feed subscription.
  55. type Subscription struct {
  56. Title string `json:"title"`
  57. URL string `json:"url"`
  58. Type string `json:"type"`
  59. }
  60. func (s Subscription) String() string {
  61. return fmt.Sprintf(`Title="%s", URL="%s", Type="%s"`, s.Title, s.URL, s.Type)
  62. }
  63. // Subscriptions represents a list of subscriptions.
  64. type Subscriptions []*Subscription
  65. // Feed represents a Miniflux feed.
  66. type Feed struct {
  67. ID int64 `json:"id"`
  68. UserID int64 `json:"user_id"`
  69. FeedURL string `json:"feed_url"`
  70. SiteURL string `json:"site_url"`
  71. Title string `json:"title"`
  72. CheckedAt time.Time `json:"checked_at,omitempty"`
  73. EtagHeader string `json:"etag_header,omitempty"`
  74. LastModifiedHeader string `json:"last_modified_header,omitempty"`
  75. ParsingErrorMsg string `json:"parsing_error_message,omitempty"`
  76. ParsingErrorCount int `json:"parsing_error_count,omitempty"`
  77. ScraperRules string `json:"scraper_rules"`
  78. RewriteRules string `json:"rewrite_rules"`
  79. Crawler bool `json:"crawler"`
  80. Username string `json:"username"`
  81. Password string `json:"password"`
  82. Category *Category `json:"category,omitempty"`
  83. Entries Entries `json:"entries,omitempty"`
  84. }
  85. // FeedModification represents changes for a feed.
  86. type FeedModification struct {
  87. FeedURL *string `json:"feed_url"`
  88. SiteURL *string `json:"site_url"`
  89. Title *string `json:"title"`
  90. ScraperRules *string `json:"scraper_rules"`
  91. RewriteRules *string `json:"rewrite_rules"`
  92. Crawler *bool `json:"crawler"`
  93. Username *string `json:"username"`
  94. Password *string `json:"password"`
  95. CategoryID *int64 `json:"category_id"`
  96. }
  97. // FeedIcon represents the feed icon.
  98. type FeedIcon struct {
  99. ID int64 `json:"id"`
  100. MimeType string `json:"mime_type"`
  101. Data string `json:"data"`
  102. }
  103. // Feeds represents a list of feeds.
  104. type Feeds []*Feed
  105. // Entry represents a subscription item in the system.
  106. type Entry struct {
  107. ID int64 `json:"id"`
  108. UserID int64 `json:"user_id"`
  109. FeedID int64 `json:"feed_id"`
  110. Status string `json:"status"`
  111. Hash string `json:"hash"`
  112. Title string `json:"title"`
  113. URL string `json:"url"`
  114. Date time.Time `json:"published_at"`
  115. Content string `json:"content"`
  116. Author string `json:"author"`
  117. Starred bool `json:"starred"`
  118. Enclosures Enclosures `json:"enclosures,omitempty"`
  119. Feed *Feed `json:"feed,omitempty"`
  120. Category *Category `json:"category,omitempty"`
  121. }
  122. // Entries represents a list of entries.
  123. type Entries []*Entry
  124. // Enclosure represents an attachment.
  125. type Enclosure struct {
  126. ID int64 `json:"id"`
  127. UserID int64 `json:"user_id"`
  128. EntryID int64 `json:"entry_id"`
  129. URL string `json:"url"`
  130. MimeType string `json:"mime_type"`
  131. Size int `json:"size"`
  132. }
  133. // Enclosures represents a list of attachments.
  134. type Enclosures []*Enclosure
  135. // Filter is used to filter entries.
  136. type Filter struct {
  137. Status string
  138. Offset int
  139. Limit int
  140. Order string
  141. Direction string
  142. Starred bool
  143. Before int64
  144. After int64
  145. BeforeEntryID int64
  146. AfterEntryID int64
  147. }
  148. // EntryResultSet represents the response when fetching entries.
  149. type EntryResultSet struct {
  150. Total int `json:"total"`
  151. Entries Entries `json:"entries"`
  152. }