app

package
v0.1.0-a6 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GithubHostname define the hostname for github urls
	GithubHostname = "github.com"
	// GithubAPIURL define the api URL for github
	GithubAPIURL = "https://api.github.com"
)
View Source
const (
	// TemplateEmailNotificationsFile define the path to the EmailNotification template file
	TemplateEmailNotificationsFile = "templates/email_notifications.gohtml"
)

Variables

This section is empty.

Functions

func CallGet

func CallGet(endpoint string) ([]byte, *model.AppError)

CallGet is used to call remote APIs to fetch data

func NewNotificationsEmail

func NewNotificationsEmail(data *model.UserNotifications) (string, string, *model.AppError)

NewNotificationsEmail email

Types

type App

type App struct {
	Config      *conf.Config
	Logger      *clog.Logger
	Store       store.Store
	Runner      *Runner
	EmailClient *EmailClient
	Crawlers    map[string]Crawler

	IsRunning struct {
		Crawler bool
	}

	ErrorCh chan *model.AppError
}

App structure

func Init

func Init() *App

Init app

func (*App) Close

func (app *App) Close()

Close the app

func (*App) CrawlSoftware

func (a *App) CrawlSoftware(notificationCh chan<- *model.Notification, software model.Software)

CrawlSoftware check latest software version and push a new notification in a channel

func (*App) CrawlSoftwares

func (a *App) CrawlSoftwares() *model.AppError

CrawlSoftwares get all softwares and get latest version to compare

func (*App) DispatchNotifications

func (a *App) DispatchNotifications() chan *model.Notification

DispatchNotifications listen for any new notification and dispatch the notification to users by email

func (*App) Housekeeping

func (a *App) Housekeeping() *model.AppError

Housekeeping clean up databse, reindex database, remove unused data, email unverified users

func (*App) LoadCrawlers

func (a *App) LoadCrawlers()

LoadCrawlers creates the crawlers and add push them into the app

func (*App) LoadDefaultData

func (a *App) LoadDefaultData() *model.AppError

LoadDefaultData save the first system user and load the predifined softwares and categories

type Confirmation

type Confirmation struct {
	model.User
	Link string
}

Confirmation structure

type Crawler

type Crawler interface {
	FetchVersion(sourceURL *url.URL) (*model.Version, *model.AppError)
}

Crawler define all the required function for a version crawler

func NewCrawlerGithub

func NewCrawlerGithub(clientID string, clientSecret string) Crawler

NewCrawlerGithub create a new crawler for github

type CrawlerGithub

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

CrawlerGithub is the struct used to crawl github repositories

func (*CrawlerGithub) FetchVersion

func (c *CrawlerGithub) FetchVersion(sourceURL *url.URL) (*model.Version, *model.AppError)

FetchVersion fetches latest version of the specified github repo

type DefaultData

type DefaultData struct {
	Softwares []struct {
		Name           string   `yaml:"name"`
		Description    string   `yaml:"description"`
		Website        string   `yaml:"website"`
		Repository     string   `yaml:"repository"`
		RepositoryType string   `yaml:"repository_type"`
		Categories     []string `yaml:"categories"`
	} `yaml:"softwares"`
}

DefaultData struct

type EmailClient

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

EmailClient struct

func NewEmailClient

func NewEmailClient(host string, port int, username string, password string, from string, errorCh chan<- *model.AppError) (*EmailClient, *model.AppError)

NewEmailClient creates a new client and returns it into the app

func (*EmailClient) Close

func (s *EmailClient) Close()

Close email client

func (*EmailClient) Send

func (s *EmailClient) Send(to string, subject string, body string) *model.AppError

Send new notifications trough email client

type Runner

type Runner struct {
	Cron *cron.Cron
}

Runner structure

func NewRunner

func NewRunner(location string, errorCh chan<- *model.AppError) (*Runner, *model.AppError)

NewRunner creates a new job runner and returns it into the app

func (*Runner) Close

func (o *Runner) Close()

Close the runner

Jump to

Keyboard shortcuts

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