aggregator

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotModified = errors.New("not modified")

Functions

func GetFoldersMap added in v0.3.0

func GetFoldersMap(db *server.DB) (map[string]*common.Folder, error)

Types

type Account added in v0.4.0

type Account struct {
	ID          ID     `json:"id"`
	Username    string `json:"username"`
	Acct        string `json:"acct"`
	DisplayName string `json:"display_name"`
	URL         string `json:"url"`
	Avatar      string `json:"avatar"`
}

type Attachment added in v0.4.0

type Attachment struct {
	ID   ID             `json:"id"`
	Type string         `json:"type"`
	URL  string         `json:"url"`
	Meta AttachmentMeta `json:"meta"`
}

type AttachmentMeta added in v0.4.0

type AttachmentMeta struct {
	Original AttachmentSize `json:"original"`
	Small    AttachmentSize `json:"small"`
}

type AttachmentSize added in v0.4.0

type AttachmentSize struct {
	Width  int64   `json:"width"`
	Height int64   `json:"height"`
	Size   string  `json:"size"`
	Aspect float64 `json:"aspect"`
}

type BlueSkyPoller added in v0.5.0

type BlueSkyPoller struct {
	// contains filtered or unexported fields
}

BlueSkyPoller represents a polling client for the BlueSky social network. It manages authentication, connection details, and handles data streaming through channels. The struct maintains client state including tokens, account information, and database connections.

func NewBlueSkyPoller added in v0.5.0

func NewBlueSkyPoller(cfg *common.Config, db *server.DB, newCh chan common.AggregatorItem) (*BlueSkyPoller, error)

NewBlueSkyPoller creates a new instance of BlueSkyPoller with the provided configuration, database connection, and channel for new items. It returns a pointer to the BlueSkyPoller and an error if initialization fails.

func (*BlueSkyPoller) APICall added in v0.5.0

func (m *BlueSkyPoller) APICall(ctx context.Context, method, path string, params map[string]string) ([]byte, error)

APICall makes an HTTP request to the BlueSky API with the specified method, path, and parameters. It handles both GET and POST requests, automatically managing authentication tokens and request formatting. The method refreshes the access token if it's close to expiration. Returns the raw response body as bytes and any error encountered.

func (*BlueSkyPoller) Authorize added in v0.5.0

func (m *BlueSkyPoller) Authorize(ctx context.Context) error

Authorize performs the authentication process with the BlueSky API. It retrieves the DID, creates a session, and obtains access and refresh tokens. It also loads the current account information after successful authorization.

func (*BlueSkyPoller) GetAccount added in v0.5.0

func (m *BlueSkyPoller) GetAccount(ctx context.Context) (*bluesky.Account, error)

GetAccount retrieves the account profile information for the current handle by making a request to the BlueSky API. It returns a populated Account struct.

func (*BlueSkyPoller) GetDID added in v0.5.0

func (m *BlueSkyPoller) GetDID(ctx context.Context) (string, error)

GetDID retrieves the Decentralized Identifier (DID) for the account handle by making a request to the BlueSky API. It caches the DID in the poller instance.

func (*BlueSkyPoller) GetTimelineHome added in v0.5.0

func (m *BlueSkyPoller) GetTimelineHome(ctx context.Context, pagination *bluesky.Pagination) ([]*bsky.FeedDefs_FeedViewPost, error)

GetTimelineHome retrieves the home timeline posts for the authenticated user. It accepts pagination parameters and returns a slice of FeedViewPost objects.

func (*BlueSkyPoller) GrabTimeline added in v0.5.0

func (m *BlueSkyPoller) GrabTimeline()

GrabTimeline continuously polls the BlueSky timeline for new posts. It maintains the last seen post timestamp, handles initial and subsequent calls, and sends new posts to a channel for processing. It includes error handling and implements a polling delay between requests.

type BlueskyPost added in v0.5.0

type BlueskyPost struct {
	*bsky.FeedDefs_PostView `binding:"required"`

	User *bluesky.Account
	// contains filtered or unexported fields
}

BlueskyPost represents a post from the Bluesky social network, containing the post view, reason for display, and associated user account

func (*BlueskyPost) ToDoc added in v0.5.0

func (s *BlueskyPost) ToDoc() (*common.Doc, error)

ToDoc converts a BlueskyPost into a common document format, including all post metadata, content, and media attachments

type Feed

type Feed struct {
	*gofeed.Feed

	ETag         string
	LastModified string
}

type ID added in v0.4.0

type ID string

type MastodonPoller

type MastodonPoller struct {
	// contains filtered or unexported fields
}

func NewMastodonPoller

func NewMastodonPoller(cfg *common.Config, db *server.DB, newCh chan common.AggregatorItem) (*MastodonPoller, error)

func (*MastodonPoller) APICall added in v0.4.0

func (m *MastodonPoller) APICall(ctx context.Context, method, path string, params map[string]string) ([]byte, error)

func (*MastodonPoller) Authorize added in v0.4.0

func (m *MastodonPoller) Authorize(ctx context.Context, accessToken string) error

func (*MastodonPoller) GetAccount added in v0.4.0

func (m *MastodonPoller) GetAccount(ctx context.Context) (*Account, error)

func (*MastodonPoller) GetFollowedTags added in v0.4.0

func (m *MastodonPoller) GetFollowedTags(ctx context.Context) (map[string]Tag, error)

func (*MastodonPoller) GetTimelineHome added in v0.4.0

func (m *MastodonPoller) GetTimelineHome(ctx context.Context, pagination *Pagination) ([]*Status, error)

func (*MastodonPoller) GrabTimeline

func (m *MastodonPoller) GrabTimeline()

func (*MastodonPoller) HandleHTTP

func (m *MastodonPoller) HandleHTTP(c *gin.Context)

type Pagination added in v0.4.0

type Pagination struct {
	SinceID string
	Limit   int64
}

type PollerData

type PollerData struct {
	ID          int    `json:"id,omitempty"`
	Type        string `json:"type"`
	Kind        string `json:"kind"`
	Skey        string `json:"skey"`
	LastSeenStr string `json:"last_seen_str"`
	LastSeenInt int64  `json:"last_seen_int"`
}

func GetRunData

func GetRunData(db *server.DB, skey string) *PollerData

func (*PollerData) GetID

func (p *PollerData) GetID() int

func (*PollerData) SetID

func (p *PollerData) SetID(id int)

type RssItem

type RssItem struct {
	*gofeed.Item `binding:"required"`
	FeedTitle    string         `json:"feed_title"`
	FeedUrl      string         `json:"feed_url"`
	Skey         string         `json:"skey"`
	Folder       *common.Folder `json:"folder,omitempty"`
}

func (RssItem) ToDoc

func (ri RssItem) ToDoc() (*common.Doc, error)

type RssPoller

type RssPoller struct {
	// contains filtered or unexported fields
}

func NewRssPoller

func NewRssPoller(cfg *common.Config,
	db *server.DB,
	newCh chan common.AggregatorItem,
	newSubCh chan *common.Sub) *RssPoller

func (*RssPoller) GetFromURL

func (r *RssPoller) GetFromURL(sub *common.Sub) (*Feed, error)

Calls the feed url with conditional headers. See https://github.com/mmcdole/gofeed/issues/111#issuecomment-450956821

func (*RssPoller) GrabFeed

func (r *RssPoller) GrabFeed(sub *common.Sub, folder *common.Folder) error

func (*RssPoller) GrabFeeds

func (r *RssPoller) GrabFeeds()

func (*RssPoller) HandleHTTP

func (r *RssPoller) HandleHTTP(c *gin.Context)

func (*RssPoller) HandleNewSubs

func (r *RssPoller) HandleNewSubs()

func (*RssPoller) Run

func (r *RssPoller) Run()

type Status

type Status struct {
	ID               ID           `json:"id"`
	URI              string       `json:"uri"`
	URL              string       `json:"url"`
	Account          Account      `json:"account"`
	Reblog           *Status      `json:"reblog"`
	Content          string       `json:"content"`
	CreatedAt        time.Time    `json:"created_at"`
	Reblogged        interface{}  `json:"reblogged"`
	Muted            interface{}  `json:"muted"`
	MediaAttachments []Attachment `json:"media_attachments"`
	Tags             []Tag        `json:"tags"`
	Card             *common.Card `json:"card"`
	Filtered         []interface{}
}

type Tag added in v0.4.0

type Tag struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type Toot added in v0.4.0

type Toot struct {
	*Status     `binding:"required"`
	User        *Account
	FollowedTag *Tag
}

func (*Toot) ToDoc added in v0.4.0

func (s *Toot) ToDoc() (*common.Doc, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL