🚧 A bit of initial work
This commit is contained in:
parent
84945e0f54
commit
2b888f203d
7 changed files with 326 additions and 1 deletions
69
app.go
Normal file
69
app.go
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
package lenore
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"codeberg.org/danjones000/lenore/config"
|
||||
vocab "github.com/go-ap/activitypub"
|
||||
"github.com/go-ap/client"
|
||||
boxap "github.com/go-ap/fedbox/activitypub"
|
||||
proc "github.com/go-ap/processing"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
conf config.Config
|
||||
self vocab.Service
|
||||
user vocab.Person
|
||||
version string
|
||||
storage proc.Store
|
||||
client client.C
|
||||
}
|
||||
|
||||
func NewApp(ver string, conf config.Config, db proc.Store) (*App, error) {
|
||||
if conf.BaseURL == "" {
|
||||
return nil, errors.New("Missing BaseURL")
|
||||
}
|
||||
app := App{
|
||||
version: ver,
|
||||
}
|
||||
|
||||
selfIRI := boxap.DefaultServiceIRI(conf.BaseURL)
|
||||
self, err := boxap.LoadActor(db, selfIRI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
app.self = self
|
||||
app.client = *client.New()
|
||||
|
||||
return &app, nil
|
||||
}
|
||||
|
||||
func (l *App) Config() config.Config {
|
||||
return l.conf
|
||||
}
|
||||
|
||||
func (l *App) Storage() proc.Store {
|
||||
return l.storage
|
||||
}
|
||||
|
||||
func (l *App) Service() vocab.Service {
|
||||
return l.self
|
||||
}
|
||||
|
||||
func (l *App) ServiceIRI() vocab.IRI {
|
||||
return l.self.ID
|
||||
}
|
||||
|
||||
func (l *App) User() vocab.Actor {
|
||||
return l.user
|
||||
}
|
||||
|
||||
func (l *App) Version() string {
|
||||
return l.version
|
||||
}
|
||||
|
||||
func (l *App) String() string {
|
||||
return fmt.Sprintf("Lenore (%s)", l.version)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue