Fix nil pointer on instance-wide actor lookup

Ref T820
pull/439/head
Matt Baer 4 years ago
parent 9484880bca
commit 9aeeb52bdb
  1. 12
      activitypub.go
  2. 8
      app.go

@ -45,12 +45,14 @@ const (
var instanceColl *Collection
func initActivityPub(cfg *config.Config) {
ur, _ := url.Parse(cfg.App.Host)
func initActivityPub(app *App) {
ur, _ := url.Parse(app.cfg.App.Host)
instanceColl = &Collection{
ID: 0,
Alias: ur.Host,
Title: ur.Host,
ID: 0,
Alias: ur.Host,
Title: ur.Host,
db: app.db,
hostName: app.cfg.App.Host,
}
}

@ -384,13 +384,13 @@ func Initialize(apper Apper, debug bool) (*App, error) {
apper.App().InitDecoder()
apper.App().InitActivityPub()
err = ConnectToDatabase(apper.App())
if err != nil {
return nil, fmt.Errorf("connect to DB: %s", err)
}
initActivityPub(apper.App())
// Handle local timeline, if enabled
if apper.App().cfg.App.LocalTimeline {
log.Info("Initializing local timeline...")
@ -501,10 +501,6 @@ func (app *App) InitDecoder() {
app.formDecoder.RegisterConverter(sql.NullFloat64{}, converter.ConvertSQLNullFloat64)
}
func (app *App) InitActivityPub() {
initActivityPub(app.cfg)
}
// ConnectToDatabase validates and connects to the configured database, then
// tests the connection.
func ConnectToDatabase(app *App) error {

Loading…
Cancel
Save