core.go 5.4 KB

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