miniflux/internal/model/entry.go

77 lines
2.1 KiB
Go
Raw Permalink Normal View History

// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
2017-11-20 06:10:04 +01:00
package model // import "miniflux.app/v2/internal/model"
2017-11-20 06:10:04 +01:00
import (
"time"
)
2021-01-05 00:32:32 +01:00
// Entry statuses and default sorting order.
2017-11-20 06:10:04 +01:00
const (
EntryStatusUnread = "unread"
EntryStatusRead = "read"
EntryStatusRemoved = "removed"
DefaultSortingOrder = "published_at"
2017-12-03 02:04:01 +01:00
DefaultSortingDirection = "asc"
2017-11-20 06:10:04 +01:00
)
2017-11-22 00:46:59 +01:00
// Entry represents a feed item in the system.
2017-11-20 06:10:04 +01:00
type Entry struct {
2018-04-07 22:50:45 +02: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"`
CommentsURL string `json:"comments_url"`
2018-04-07 22:50:45 +02:00
Date time.Time `json:"published_at"`
2020-11-30 02:04:18 +01:00
CreatedAt time.Time `json:"created_at"`
ChangedAt time.Time `json:"changed_at"`
2018-04-07 22:50:45 +02:00
Content string `json:"content"`
Author string `json:"author"`
ShareCode string `json:"share_code"`
2018-04-07 22:50:45 +02:00
Starred bool `json:"starred"`
ReadingTime int `json:"reading_time"`
2021-01-05 00:32:32 +01:00
Enclosures EnclosureList `json:"enclosures"`
2018-04-07 22:50:45 +02:00
Feed *Feed `json:"feed,omitempty"`
Tags []string `json:"tags"`
2017-11-20 06:10:04 +01:00
}
2023-09-09 07:45:17 +02:00
func NewEntry() *Entry {
return &Entry{
Enclosures: make(EnclosureList, 0),
Tags: make([]string, 0),
Feed: &Feed{
Category: &Category{},
Icon: &FeedIcon{},
},
2023-09-09 07:45:17 +02:00
}
}
2017-11-22 00:46:59 +01:00
// Entries represents a list of entries.
2017-11-20 06:10:04 +01:00
type Entries []*Entry
2021-01-05 00:32:32 +01:00
// EntriesStatusUpdateRequest represents a request to change entries status.
type EntriesStatusUpdateRequest struct {
EntryIDs []int64 `json:"entry_ids"`
Status string `json:"status"`
2017-11-27 00:07:59 +01:00
}
// EntryUpdateRequest represents a request to update an entry.
type EntryUpdateRequest struct {
Title *string `json:"title"`
Content *string `json:"content"`
}
func (e *EntryUpdateRequest) Patch(entry *Entry) {
if e.Title != nil && *e.Title != "" {
entry.Title = *e.Title
}
if e.Content != nil && *e.Content != "" {
entry.Content = *e.Content
}
}