core.go 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package client // import "miniflux.app/client"
  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. Stylesheet string `json:"stylesheet"`
  26. GoogleID string `json:"google_id"`
  27. OpenIDConnectID string `json:"openid_connect_id"`
  28. EntriesPerPage int `json:"entries_per_page"`
  29. KeyboardShortcuts bool `json:"keyboard_shortcuts"`
  30. ShowReadingTime bool `json:"show_reading_time"`
  31. EntrySwipe bool `json:"entry_swipe"`
  32. LastLoginAt *time.Time `json:"last_login_at"`
  33. }
  34. func (u User) String() string {
  35. return fmt.Sprintf("#%d - %s (admin=%v)", u.ID, u.Username, u.IsAdmin)
  36. }
  37. // UserCreationRequest represents the request to create a user.
  38. type UserCreationRequest struct {
  39. Username string `json:"username"`
  40. Password string `json:"password"`
  41. IsAdmin bool `json:"is_admin"`
  42. GoogleID string `json:"google_id"`
  43. OpenIDConnectID string `json:"openid_connect_id"`
  44. }
  45. // UserModification represents the request to update a user.
  46. type UserModification struct {
  47. Username *string `json:"username"`
  48. Password *string `json:"password"`
  49. IsAdmin *bool `json:"is_admin"`
  50. Theme *string `json:"theme"`
  51. Language *string `json:"language"`
  52. Timezone *string `json:"timezone"`
  53. EntryDirection *string `json:"entry_sorting_direction"`
  54. Stylesheet *string `json:"stylesheet"`
  55. GoogleID *string `json:"google_id"`
  56. OpenIDConnectID *string `json:"openid_connect_id"`
  57. EntriesPerPage *int `json:"entries_per_page"`
  58. KeyboardShortcuts *bool `json:"keyboard_shortcuts"`
  59. ShowReadingTime *bool `json:"show_reading_time"`
  60. EntrySwipe *bool `json:"entry_swipe"`
  61. }
  62. // Users represents a list of users.
  63. type Users []User
  64. // Category represents a feed category.
  65. type Category struct {
  66. ID int64 `json:"id,omitempty"`
  67. Title string `json:"title,omitempty"`
  68. UserID int64 `json:"user_id,omitempty"`
  69. }
  70. func (c Category) String() string {
  71. return fmt.Sprintf("#%d %s", c.ID, c.Title)
  72. }
  73. // Categories represents a list of categories.
  74. type Categories []*Category
  75. // Subscription represents a feed subscription.
  76. type Subscription struct {
  77. Title string `json:"title"`
  78. URL string `json:"url"`
  79. Type string `json:"type"`
  80. }
  81. func (s Subscription) String() string {
  82. return fmt.Sprintf(`Title="%s", URL="%s", Type="%s"`, s.Title, s.URL, s.Type)
  83. }
  84. // Subscriptions represents a list of subscriptions.
  85. type Subscriptions []*Subscription
  86. // Feed represents a Miniflux feed.
  87. type Feed struct {
  88. ID int64 `json:"id"`
  89. UserID int64 `json:"user_id"`
  90. FeedURL string `json:"feed_url"`
  91. SiteURL string `json:"site_url"`
  92. Title string `json:"title"`
  93. CheckedAt time.Time `json:"checked_at,omitempty"`
  94. EtagHeader string `json:"etag_header,omitempty"`
  95. LastModifiedHeader string `json:"last_modified_header,omitempty"`
  96. ParsingErrorMsg string `json:"parsing_error_message,omitempty"`
  97. ParsingErrorCount int `json:"parsing_error_count,omitempty"`
  98. ScraperRules string `json:"scraper_rules"`
  99. RewriteRules string `json:"rewrite_rules"`
  100. BlocklistRules string `json:"blocklist_rules"`
  101. KeeplistRules string `json:"keeplist_rules"`
  102. Crawler bool `json:"crawler"`
  103. UserAgent string `json:"user_agent"`
  104. Username string `json:"username"`
  105. Password string `json:"password"`
  106. Category *Category `json:"category,omitempty"`
  107. }
  108. // FeedModification represents changes for a feed.
  109. type FeedModification struct {
  110. FeedURL *string `json:"feed_url"`
  111. SiteURL *string `json:"site_url"`
  112. Title *string `json:"title"`
  113. ScraperRules *string `json:"scraper_rules"`
  114. RewriteRules *string `json:"rewrite_rules"`
  115. BlocklistRules *string `json:"blocklist_rules"`
  116. KeeplistRules *string `json:"keeplist_rules"`
  117. Crawler *bool `json:"crawler"`
  118. UserAgent *string `json:"user_agent"`
  119. Username *string `json:"username"`
  120. Password *string `json:"password"`
  121. CategoryID *int64 `json:"category_id"`
  122. Disabled *bool `json:"disabled"`
  123. IgnoreHTTPCache *bool `json:"ignore_http_cache"`
  124. FetchViaProxy *bool `json:"fetch_via_proxy"`
  125. }
  126. // FeedIcon represents the feed icon.
  127. type FeedIcon struct {
  128. ID int64 `json:"id"`
  129. MimeType string `json:"mime_type"`
  130. Data string `json:"data"`
  131. }
  132. // Feeds represents a list of feeds.
  133. type Feeds []*Feed
  134. // Entry represents a subscription item in the system.
  135. type Entry struct {
  136. ID int64 `json:"id"`
  137. UserID int64 `json:"user_id"`
  138. FeedID int64 `json:"feed_id"`
  139. Status string `json:"status"`
  140. Hash string `json:"hash"`
  141. Title string `json:"title"`
  142. URL string `json:"url"`
  143. Date time.Time `json:"published_at"`
  144. CreatedAt time.Time `json:"created_at"`
  145. Content string `json:"content"`
  146. Author string `json:"author"`
  147. ShareCode string `json:"share_code"`
  148. Starred bool `json:"starred"`
  149. ReadingTime int `json:"reading_time"`
  150. Enclosures Enclosures `json:"enclosures,omitempty"`
  151. Feed *Feed `json:"feed,omitempty"`
  152. }
  153. // Entries represents a list of entries.
  154. type Entries []*Entry
  155. // Enclosure represents an attachment.
  156. type Enclosure struct {
  157. ID int64 `json:"id"`
  158. UserID int64 `json:"user_id"`
  159. EntryID int64 `json:"entry_id"`
  160. URL string `json:"url"`
  161. MimeType string `json:"mime_type"`
  162. Size int `json:"size"`
  163. }
  164. // Enclosures represents a list of attachments.
  165. type Enclosures []*Enclosure
  166. // Filter is used to filter entries.
  167. type Filter struct {
  168. Status string
  169. Offset int
  170. Limit int
  171. Order string
  172. Direction string
  173. Starred bool
  174. Before int64
  175. After int64
  176. BeforeEntryID int64
  177. AfterEntryID int64
  178. Search string
  179. CategoryID int64
  180. FeedID int64
  181. Statuses []string
  182. }
  183. // EntryResultSet represents the response when fetching entries.
  184. type EntryResultSet struct {
  185. Total int `json:"total"`
  186. Entries Entries `json:"entries"`
  187. }