Fix nil pointer on instance-wide actor lookup

Ref T820
This commit is contained in:
Matt Baer 2021-03-08 12:50:08 -05:00
parent 9484880bca
commit 9aeeb52bdb
2 changed files with 9 additions and 11 deletions

View File

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

8
app.go
View File

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