From 9aeeb52bdb500832cad4c801817a07ad6f90a2ce Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 8 Mar 2021 12:50:08 -0500 Subject: [PATCH] Fix nil pointer on instance-wide actor lookup Ref T820 --- activitypub.go | 12 +++++++----- app.go | 8 ++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/activitypub.go b/activitypub.go index 855f9a7..9a3a3f0 100644 --- a/activitypub.go +++ b/activitypub.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, } } diff --git a/app.go b/app.go index a0e754e..d34daf5 100644 --- a/app.go +++ b/app.go @@ -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 {