core.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. EntriesPerPage int `json:"entries_per_page"`
  26. LastLoginAt *time.Time `json:"last_login_at"`
  27. Extra map[string]string `json:"extra"`
  28. }
  29. func (u User) String() string {
  30. return fmt.Sprintf("#%d - %s (admin=%v)", u.ID, u.Username, u.IsAdmin)
  31. }
  32. // UserModification is used to update a user.
  33. type UserModification struct {
  34. Username *string `json:"username"`
  35. Password *string `json:"password"`
  36. IsAdmin *bool `json:"is_admin"`
  37. Theme *string `json:"theme"`
  38. Language *string `json:"language"`
  39. Timezone *string `json:"timezone"`
  40. EntryDirection *string `json:"entry_sorting_direction"`
  41. EntriesPerPage *int `json:"entries_per_page"`
  42. }
  43. // Users represents a list of users.
  44. type Users []User
  45. // Category represents a feed category.
  46. type Category struct {
  47. ID int64 `json:"id,omitempty"`
  48. Title string `json:"title,omitempty"`
  49. UserID int64 `json:"user_id,omitempty"`
  50. }
  51. func (c Category) String() string {
  52. return fmt.Sprintf("#%d %s", c.ID, c.Title)
  53. }
  54. // Categories represents a list of categories.
  55. type Categories []*Category
  56. // Subscription represents a feed subscription.
  57. type Subscription struct {
  58. Title string `json:"title"`
  59. URL string `json:"url"`
  60. Type string `json:"type"`
  61. }
  62. func (s Subscription) String() string {
  63. return fmt.Sprintf(`Title="%s", URL="%s", Type="%s"`, s.Title, s.URL, s.Type)
  64. }
  65. // Subscriptions represents a list of subscriptions.
  66. type Subscriptions []*Subscription
  67. // Feed represents a Miniflux feed.
  68. type Feed struct {
  69. ID int64 `json:"id"`
  70. UserID int64 `json:"user_id"`
  71. FeedURL string `json:"feed_url"`
  72. SiteURL string `json:"site_url"`
  73. Title string `json:"title"`
  74. CheckedAt time.Time `json:"checked_at,omitempty"`
  75. EtagHeader string `json:"etag_header,omitempty"`
  76. LastModifiedHeader string `json:"last_modified_header,omitempty"`
  77. ParsingErrorMsg string `json:"parsing_error_message,omitempty"`
  78. ParsingErrorCount int `json:"parsing_error_count,omitempty"`
  79. ScraperRules string `json:"scraper_rules"`
  80. RewriteRules string `json:"rewrite_rules"`
  81. BlocklistRules string `json:"blocklist_rules"`
  82. KeeplistRules string `json:"keeplist_rules"`
  83. Crawler bool `json:"crawler"`
  84. UserAgent string `json:"user_agent"`
  85. Username string `json:"username"`
  86. Password string `json:"password"`
  87. Category *Category `json:"category,omitempty"`
  88. }
  89. // FeedModification represents changes for a feed.
  90. type FeedModification struct {
  91. FeedURL *string `json:"feed_url"`
  92. SiteURL *string `json:"site_url"`
  93. Title *string `json:"title"`
  94. ScraperRules *string `json:"scraper_rules"`
  95. RewriteRules *string `json:"rewrite_rules"`
  96. BlocklistRules *string `json:"blocklist_rules"`
  97. KeeplistRules *string `json:"keeplist_rules"`
  98. Crawler *bool `json:"crawler"`
  99. UserAgent *string `json:"user_agent"`
  100. Username *string `json:"username"`
  101. Password *string `json:"password"`
  102. CategoryID *int64 `json:"category_id"`
  103. }
  104. // FeedIcon represents the feed icon.
  105. type FeedIcon struct {
  106. ID int64 `json:"id"`
  107. MimeType string `json:"mime_type"`
  108. Data string `json:"data"`
  109. }
  110. // Feeds represents a list of feeds.
  111. type Feeds []*Feed
  112. // Entry represents a subscription item in the system.
  113. type Entry struct {
  114. ID int64 `json:"id"`
  115. UserID int64 `json:"user_id"`
  116. FeedID int64 `json:"feed_id"`
  117. Status string `json:"status"`
  118. Hash string `json:"hash"`
  119. Title string `json:"title"`
  120. URL string `json:"url"`
  121. Date time.Time `json:"published_at"`
  122. Content string `json:"content"`
  123. Author string `json:"author"`
  124. ShareCode string `json:"share_code"`
  125. Starred bool `json:"starred"`
  126. Enclosures Enclosures `json:"enclosures,omitempty"`
  127. Feed *Feed `json:"feed,omitempty"`
  128. }
  129. // Entries represents a list of entries.
  130. type Entries []*Entry
  131. // Enclosure represents an attachment.
  132. type Enclosure struct {
  133. ID int64 `json:"id"`
  134. UserID int64 `json:"user_id"`
  135. EntryID int64 `json:"entry_id"`
  136. URL string `json:"url"`
  137. MimeType string `json:"mime_type"`
  138. Size int `json:"size"`
  139. }
  140. // Enclosures represents a list of attachments.
  141. type Enclosures []*Enclosure
  142. // Filter is used to filter entries.
  143. type Filter struct {
  144. Status string
  145. Offset int
  146. Limit int
  147. Order string
  148. Direction string
  149. Starred bool
  150. Before int64
  151. After int64
  152. BeforeEntryID int64
  153. AfterEntryID int64
  154. Search string
  155. CategoryID int64
  156. FeedID int64
  157. Statuses []string
  158. }
  159. // EntryResultSet represents the response when fetching entries.
  160. type EntryResultSet struct {
  161. Total int `json:"total"`
  162. Entries Entries `json:"entries"`
  163. }