core.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. 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 feed category.
  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. UserAgent string `json:"user_agent"`
  81. Username string `json:"username"`
  82. Password string `json:"password"`
  83. Category *Category `json:"category,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. UserAgent *string `json:"user_agent"`
  94. Username *string `json:"username"`
  95. Password *string `json:"password"`
  96. CategoryID *int64 `json:"category_id"`
  97. }
  98. // FeedIcon represents the feed icon.
  99. type FeedIcon struct {
  100. ID int64 `json:"id"`
  101. MimeType string `json:"mime_type"`
  102. Data string `json:"data"`
  103. }
  104. // Feeds represents a list of feeds.
  105. type Feeds []*Feed
  106. // Entry represents a subscription item in the system.
  107. type Entry struct {
  108. ID int64 `json:"id"`
  109. UserID int64 `json:"user_id"`
  110. FeedID int64 `json:"feed_id"`
  111. Status string `json:"status"`
  112. Hash string `json:"hash"`
  113. Title string `json:"title"`
  114. URL string `json:"url"`
  115. Date time.Time `json:"published_at"`
  116. Content string `json:"content"`
  117. Author string `json:"author"`
  118. ShareCode string `json:"share_code"`
  119. Starred bool `json:"starred"`
  120. Enclosures Enclosures `json:"enclosures,omitempty"`
  121. Feed *Feed `json:"feed,omitempty"`
  122. }
  123. // Entries represents a list of entries.
  124. type Entries []*Entry
  125. // Enclosure represents an attachment.
  126. type Enclosure struct {
  127. ID int64 `json:"id"`
  128. UserID int64 `json:"user_id"`
  129. EntryID int64 `json:"entry_id"`
  130. URL string `json:"url"`
  131. MimeType string `json:"mime_type"`
  132. Size int `json:"size"`
  133. }
  134. // Enclosures represents a list of attachments.
  135. type Enclosures []*Enclosure
  136. // Filter is used to filter entries.
  137. type Filter struct {
  138. Status string
  139. Offset int
  140. Limit int
  141. Order string
  142. Direction string
  143. Starred bool
  144. Before int64
  145. After int64
  146. BeforeEntryID int64
  147. AfterEntryID int64
  148. Search string
  149. CategoryID int64
  150. }
  151. // EntryResultSet represents the response when fetching entries.
  152. type EntryResultSet struct {
  153. Total int `json:"total"`
  154. Entries Entries `json:"entries"`
  155. }