You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

core.go 5.4KB

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