2023-06-19 23:42:47 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2017-11-25 19:40:23 +01:00
|
|
|
|
2018-08-25 07:23:03 +02:00
|
|
|
package client // import "miniflux.app/client"
|
2017-11-25 19:40:23 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Entry statuses.
|
|
|
|
const (
|
|
|
|
EntryStatusUnread = "unread"
|
|
|
|
EntryStatusRead = "read"
|
|
|
|
EntryStatusRemoved = "removed"
|
|
|
|
)
|
|
|
|
|
|
|
|
// User represents a user in the system.
|
|
|
|
type User struct {
|
2022-10-26 05:00:56 +02:00
|
|
|
ID int64 `json:"id"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
Password string `json:"password,omitempty"`
|
|
|
|
IsAdmin bool `json:"is_admin"`
|
|
|
|
Theme string `json:"theme"`
|
|
|
|
Language string `json:"language"`
|
|
|
|
Timezone string `json:"timezone"`
|
|
|
|
EntryDirection string `json:"entry_sorting_direction"`
|
|
|
|
EntryOrder string `json:"entry_sorting_order"`
|
|
|
|
Stylesheet string `json:"stylesheet"`
|
|
|
|
GoogleID string `json:"google_id"`
|
|
|
|
OpenIDConnectID string `json:"openid_connect_id"`
|
|
|
|
EntriesPerPage int `json:"entries_per_page"`
|
|
|
|
KeyboardShortcuts bool `json:"keyboard_shortcuts"`
|
|
|
|
ShowReadingTime bool `json:"show_reading_time"`
|
|
|
|
EntrySwipe bool `json:"entry_swipe"`
|
2022-09-30 07:37:57 +02:00
|
|
|
GestureNav string `json:"gesture_nav"`
|
2022-10-26 05:00:56 +02:00
|
|
|
LastLoginAt *time.Time `json:"last_login_at"`
|
|
|
|
DisplayMode string `json:"display_mode"`
|
|
|
|
DefaultReadingSpeed int `json:"default_reading_speed"`
|
|
|
|
CJKReadingSpeed int `json:"cjk_reading_speed"`
|
|
|
|
DefaultHomePage string `json:"default_home_page"`
|
|
|
|
CategoriesSortingOrder string `json:"categories_sorting_order"`
|
2017-11-25 19:40:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (u User) String() string {
|
|
|
|
return fmt.Sprintf("#%d - %s (admin=%v)", u.ID, u.Username, u.IsAdmin)
|
|
|
|
}
|
|
|
|
|
2020-12-22 07:05:47 +01:00
|
|
|
// UserCreationRequest represents the request to create a user.
|
|
|
|
type UserCreationRequest struct {
|
|
|
|
Username string `json:"username"`
|
|
|
|
Password string `json:"password"`
|
|
|
|
IsAdmin bool `json:"is_admin"`
|
|
|
|
GoogleID string `json:"google_id"`
|
|
|
|
OpenIDConnectID string `json:"openid_connect_id"`
|
|
|
|
}
|
|
|
|
|
2021-01-03 01:33:41 +01:00
|
|
|
// UserModificationRequest represents the request to update a user.
|
|
|
|
type UserModificationRequest struct {
|
2022-10-26 05:00:56 +02:00
|
|
|
Username *string `json:"username"`
|
|
|
|
Password *string `json:"password"`
|
|
|
|
IsAdmin *bool `json:"is_admin"`
|
|
|
|
Theme *string `json:"theme"`
|
|
|
|
Language *string `json:"language"`
|
|
|
|
Timezone *string `json:"timezone"`
|
|
|
|
EntryDirection *string `json:"entry_sorting_direction"`
|
|
|
|
EntryOrder *string `json:"entry_sorting_order"`
|
|
|
|
Stylesheet *string `json:"stylesheet"`
|
|
|
|
GoogleID *string `json:"google_id"`
|
|
|
|
OpenIDConnectID *string `json:"openid_connect_id"`
|
|
|
|
EntriesPerPage *int `json:"entries_per_page"`
|
|
|
|
KeyboardShortcuts *bool `json:"keyboard_shortcuts"`
|
|
|
|
ShowReadingTime *bool `json:"show_reading_time"`
|
|
|
|
EntrySwipe *bool `json:"entry_swipe"`
|
2022-09-30 07:37:57 +02:00
|
|
|
GestureNav *string `json:"gesture_nav"`
|
2022-10-26 05:00:56 +02:00
|
|
|
DisplayMode *string `json:"display_mode"`
|
|
|
|
DefaultReadingSpeed *int `json:"default_reading_speed"`
|
|
|
|
CJKReadingSpeed *int `json:"cjk_reading_speed"`
|
|
|
|
DefaultHomePage *string `json:"default_home_page"`
|
|
|
|
CategoriesSortingOrder *string `json:"categories_sorting_order"`
|
2018-06-24 01:16:54 +02:00
|
|
|
}
|
|
|
|
|
2017-11-25 19:40:23 +01:00
|
|
|
// Users represents a list of users.
|
|
|
|
type Users []User
|
|
|
|
|
2019-11-18 07:53:11 +01:00
|
|
|
// Category represents a feed category.
|
2017-11-25 19:40:23 +01:00
|
|
|
type Category struct {
|
|
|
|
ID int64 `json:"id,omitempty"`
|
|
|
|
Title string `json:"title,omitempty"`
|
|
|
|
UserID int64 `json:"user_id,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Category) String() string {
|
|
|
|
return fmt.Sprintf("#%d %s", c.ID, c.Title)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Categories represents a list of categories.
|
|
|
|
type Categories []*Category
|
|
|
|
|
|
|
|
// Subscription represents a feed subscription.
|
|
|
|
type Subscription struct {
|
|
|
|
Title string `json:"title"`
|
|
|
|
URL string `json:"url"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s Subscription) String() string {
|
|
|
|
return fmt.Sprintf(`Title="%s", URL="%s", Type="%s"`, s.Title, s.URL, s.Type)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subscriptions represents a list of subscriptions.
|
|
|
|
type Subscriptions []*Subscription
|
|
|
|
|
|
|
|
// Feed represents a Miniflux feed.
|
|
|
|
type Feed struct {
|
2021-02-21 22:42:49 +01:00
|
|
|
ID int64 `json:"id"`
|
|
|
|
UserID int64 `json:"user_id"`
|
|
|
|
FeedURL string `json:"feed_url"`
|
|
|
|
SiteURL string `json:"site_url"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
CheckedAt time.Time `json:"checked_at,omitempty"`
|
|
|
|
EtagHeader string `json:"etag_header,omitempty"`
|
|
|
|
LastModifiedHeader string `json:"last_modified_header,omitempty"`
|
|
|
|
ParsingErrorMsg string `json:"parsing_error_message,omitempty"`
|
|
|
|
ParsingErrorCount int `json:"parsing_error_count,omitempty"`
|
|
|
|
Disabled bool `json:"disabled"`
|
|
|
|
IgnoreHTTPCache bool `json:"ignore_http_cache"`
|
|
|
|
AllowSelfSignedCertificates bool `json:"allow_self_signed_certificates"`
|
|
|
|
FetchViaProxy bool `json:"fetch_via_proxy"`
|
|
|
|
ScraperRules string `json:"scraper_rules"`
|
|
|
|
RewriteRules string `json:"rewrite_rules"`
|
|
|
|
BlocklistRules string `json:"blocklist_rules"`
|
|
|
|
KeeplistRules string `json:"keeplist_rules"`
|
|
|
|
Crawler bool `json:"crawler"`
|
|
|
|
UserAgent string `json:"user_agent"`
|
2021-03-23 04:27:58 +01:00
|
|
|
Cookie string `json:"cookie"`
|
2021-02-21 22:42:49 +01:00
|
|
|
Username string `json:"username"`
|
|
|
|
Password string `json:"password"`
|
|
|
|
Category *Category `json:"category,omitempty"`
|
2021-08-15 17:32:43 +02:00
|
|
|
HideGlobally bool `json:"hide_globally"`
|
2017-11-25 19:40:23 +01:00
|
|
|
}
|
|
|
|
|
2021-01-03 01:33:41 +01:00
|
|
|
// FeedCreationRequest represents the request to create a feed.
|
|
|
|
type FeedCreationRequest struct {
|
2021-02-21 22:42:49 +01:00
|
|
|
FeedURL string `json:"feed_url"`
|
|
|
|
CategoryID int64 `json:"category_id"`
|
|
|
|
UserAgent string `json:"user_agent"`
|
2021-03-23 04:27:58 +01:00
|
|
|
Cookie string `json:"cookie"`
|
2021-02-21 22:42:49 +01:00
|
|
|
Username string `json:"username"`
|
|
|
|
Password string `json:"password"`
|
|
|
|
Crawler bool `json:"crawler"`
|
|
|
|
Disabled bool `json:"disabled"`
|
|
|
|
IgnoreHTTPCache bool `json:"ignore_http_cache"`
|
|
|
|
AllowSelfSignedCertificates bool `json:"allow_self_signed_certificates"`
|
|
|
|
FetchViaProxy bool `json:"fetch_via_proxy"`
|
|
|
|
ScraperRules string `json:"scraper_rules"`
|
|
|
|
RewriteRules string `json:"rewrite_rules"`
|
|
|
|
BlocklistRules string `json:"blocklist_rules"`
|
|
|
|
KeeplistRules string `json:"keeplist_rules"`
|
2021-08-15 17:32:43 +02:00
|
|
|
HideGlobally bool `json:"hide_globally"`
|
2021-01-03 01:33:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// FeedModificationRequest represents the request to update a feed.
|
|
|
|
type FeedModificationRequest struct {
|
2021-02-21 22:42:49 +01:00
|
|
|
FeedURL *string `json:"feed_url"`
|
|
|
|
SiteURL *string `json:"site_url"`
|
|
|
|
Title *string `json:"title"`
|
|
|
|
ScraperRules *string `json:"scraper_rules"`
|
|
|
|
RewriteRules *string `json:"rewrite_rules"`
|
|
|
|
BlocklistRules *string `json:"blocklist_rules"`
|
|
|
|
KeeplistRules *string `json:"keeplist_rules"`
|
|
|
|
Crawler *bool `json:"crawler"`
|
|
|
|
UserAgent *string `json:"user_agent"`
|
2021-03-23 04:27:58 +01:00
|
|
|
Cookie *string `json:"cookie"`
|
2021-02-21 22:42:49 +01:00
|
|
|
Username *string `json:"username"`
|
|
|
|
Password *string `json:"password"`
|
|
|
|
CategoryID *int64 `json:"category_id"`
|
|
|
|
Disabled *bool `json:"disabled"`
|
|
|
|
IgnoreHTTPCache *bool `json:"ignore_http_cache"`
|
|
|
|
AllowSelfSignedCertificates *bool `json:"allow_self_signed_certificates"`
|
|
|
|
FetchViaProxy *bool `json:"fetch_via_proxy"`
|
2021-08-15 17:32:43 +02:00
|
|
|
HideGlobally *bool `json:"hide_globally"`
|
2018-06-24 01:16:54 +02:00
|
|
|
}
|
|
|
|
|
2017-12-16 20:25:18 +01:00
|
|
|
// FeedIcon represents the feed icon.
|
|
|
|
type FeedIcon struct {
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
MimeType string `json:"mime_type"`
|
|
|
|
Data string `json:"data"`
|
|
|
|
}
|
|
|
|
|
2022-05-21 20:44:56 +02:00
|
|
|
type FeedCounters struct {
|
|
|
|
ReadCounters map[int64]int `json:"reads"`
|
|
|
|
UnreadCounters map[int64]int `json:"unreads"`
|
|
|
|
}
|
|
|
|
|
2017-11-25 19:40:23 +01:00
|
|
|
// Feeds represents a list of feeds.
|
|
|
|
type Feeds []*Feed
|
|
|
|
|
|
|
|
// Entry represents a subscription item in the system.
|
|
|
|
type Entry struct {
|
2020-11-19 02:29:40 +01:00
|
|
|
ID int64 `json:"id"`
|
|
|
|
UserID int64 `json:"user_id"`
|
|
|
|
FeedID int64 `json:"feed_id"`
|
|
|
|
Status string `json:"status"`
|
|
|
|
Hash string `json:"hash"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
URL string `json:"url"`
|
2021-06-04 22:08:19 +02:00
|
|
|
CommentsURL string `json:"comments_url"`
|
2020-11-19 02:29:40 +01:00
|
|
|
Date time.Time `json:"published_at"`
|
2020-11-30 02:04:18 +01:00
|
|
|
CreatedAt time.Time `json:"created_at"`
|
2021-05-26 07:13:38 +02:00
|
|
|
ChangedAt time.Time `json:"changed_at"`
|
2020-11-19 02:29:40 +01:00
|
|
|
Content string `json:"content"`
|
|
|
|
Author string `json:"author"`
|
|
|
|
ShareCode string `json:"share_code"`
|
|
|
|
Starred bool `json:"starred"`
|
|
|
|
ReadingTime int `json:"reading_time"`
|
|
|
|
Enclosures Enclosures `json:"enclosures,omitempty"`
|
|
|
|
Feed *Feed `json:"feed,omitempty"`
|
2023-02-25 05:52:45 +01:00
|
|
|
Tags []string `json:"tags"`
|
2017-11-25 19:40:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Entries represents a list of entries.
|
|
|
|
type Entries []*Entry
|
|
|
|
|
|
|
|
// Enclosure represents an attachment.
|
|
|
|
type Enclosure struct {
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
UserID int64 `json:"user_id"`
|
|
|
|
EntryID int64 `json:"entry_id"`
|
|
|
|
URL string `json:"url"`
|
|
|
|
MimeType string `json:"mime_type"`
|
|
|
|
Size int `json:"size"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enclosures represents a list of attachments.
|
|
|
|
type Enclosures []*Enclosure
|
|
|
|
|
2022-04-14 06:53:06 +02:00
|
|
|
const (
|
|
|
|
FilterNotStarred = "0"
|
|
|
|
FilterOnlyStarred = "1"
|
|
|
|
)
|
|
|
|
|
2017-11-25 19:40:23 +01:00
|
|
|
// Filter is used to filter entries.
|
|
|
|
type Filter struct {
|
2018-06-10 04:13:41 +02:00
|
|
|
Status string
|
|
|
|
Offset int
|
|
|
|
Limit int
|
|
|
|
Order string
|
|
|
|
Direction string
|
2022-04-14 06:53:06 +02:00
|
|
|
Starred string
|
2018-06-10 04:13:41 +02:00
|
|
|
Before int64
|
|
|
|
After int64
|
|
|
|
BeforeEntryID int64
|
|
|
|
AfterEntryID int64
|
2018-07-07 21:02:59 +02:00
|
|
|
Search string
|
2019-11-18 07:53:11 +01:00
|
|
|
CategoryID int64
|
2020-09-15 05:03:24 +02:00
|
|
|
FeedID int64
|
|
|
|
Statuses []string
|
2017-11-25 19:40:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// EntryResultSet represents the response when fetching entries.
|
|
|
|
type EntryResultSet struct {
|
|
|
|
Total int `json:"total"`
|
|
|
|
Entries Entries `json:"entries"`
|
|
|
|
}
|