website-feeds

Make RSS feeds of your favorite "vote on posts" websites

git clone https://code.pdelong.com/website-feeds.git

  1package model
  2
  3import (
  4	"net/netip"
  5	"time"
  6)
  7
  8type SiteLastFetched struct {
  9	Time time.Time
 10	Num  int
 11}
 12
 13func (s *SiteLastFetched) Clone() *SiteLastFetched {
 14	if s == nil {
 15		return nil
 16	} else {
 17		return &SiteLastFetched{
 18			Time: s.Time,
 19			Num:  s.Num,
 20		}
 21	}
 22}
 23
 24type Site struct {
 25	ID          int
 26	Name        string
 27	DisplayName string
 28	LastFetched *SiteLastFetched
 29}
 30
 31func (s *Site) Clone() *Site {
 32	if s == nil {
 33		return nil
 34	} else {
 35		return &Site{
 36			ID:          s.ID,
 37			Name:        s.Name,
 38			DisplayName: s.DisplayName,
 39			LastFetched: s.LastFetched.Clone(),
 40		}
 41	}
 42}
 43
 44type RedditSettings struct {
 45	ClientID     string
 46	ClientSecret string
 47}
 48
 49func (r *RedditSettings) Clone() *RedditSettings {
 50	if r == nil {
 51		return nil
 52	} else {
 53		return &RedditSettings{
 54			ClientID:     r.ClientID,
 55			ClientSecret: r.ClientSecret,
 56		}
 57	}
 58}
 59
 60type Settings struct {
 61	Reddit          *RedditSettings
 62	DefaultNumPosts int
 63	MaxNumPosts     int
 64	SiteFetchWait   time.Duration
 65}
 66
 67func (s *Settings) Clone() *Settings {
 68	if s == nil {
 69		return nil
 70	} else {
 71		return &Settings{
 72			Reddit:          s.Reddit.Clone(),
 73			DefaultNumPosts: s.DefaultNumPosts,
 74			MaxNumPosts:     s.MaxNumPosts,
 75			SiteFetchWait:   s.SiteFetchWait,
 76		}
 77	}
 78}
 79
 80type Request struct {
 81	ID              int64
 82	Host            netip.AddrPort
 83	SiteId          int
 84	NumPosts        int
 85	DefaultNumPosts bool
 86	Timestamp       time.Time
 87}
 88
 89func (r *Request) Clone() *Request {
 90	if r == nil {
 91		return nil
 92	} else {
 93		out := *r
 94		return &out
 95	}
 96}
 97
 98type Post struct {
 99	SiteUniqueID string
100	Title        string
101	Score        int
102	Created      time.Time
103	URL          *string
104}
105
106func (p *Post) Clone() *Post {
107	if p == nil {
108		return nil
109	} else {
110		out := *p
111		if p.URL != nil {
112			url := *p.URL
113			p.URL = &url
114		}
115		return &out
116	}
117}