Don't federate anything when instance is private

Ref T576
pull/123/head
Matt Baer 6 years ago
parent 35718cd239
commit 63b536ec87
  1. 8
      posts.go

@ -586,7 +586,7 @@ func newPost(app *App, w http.ResponseWriter, r *http.Request) error {
// Write success now // Write success now
response := impart.WriteSuccess(w, newPost, http.StatusCreated) response := impart.WriteSuccess(w, newPost, http.StatusCreated)
if newPost.Collection != nil && app.cfg.App.Federation && !newPost.Created.After(time.Now()) { if newPost.Collection != nil && !app.cfg.App.Private && app.cfg.App.Federation && !newPost.Created.After(time.Now()) {
go federatePost(app, newPost, newPost.Collection.ID, false) go federatePost(app, newPost, newPost.Collection.ID, false)
} }
@ -686,7 +686,7 @@ func existingPost(app *App, w http.ResponseWriter, r *http.Request) error {
if pRes.CollectionID.Valid { if pRes.CollectionID.Valid {
coll, err := app.db.GetCollectionBy("id = ?", pRes.CollectionID.Int64) coll, err := app.db.GetCollectionBy("id = ?", pRes.CollectionID.Int64)
if err == nil && app.cfg.App.Federation { if err == nil && !app.cfg.App.Private && app.cfg.App.Federation {
pRes.Collection = &CollectionObj{Collection: *coll} pRes.Collection = &CollectionObj{Collection: *coll}
go federatePost(app, pRes, pRes.Collection.ID, true) go federatePost(app, pRes, pRes.Collection.ID, true)
} }
@ -826,7 +826,7 @@ func deletePost(app *App, w http.ResponseWriter, r *http.Request) error {
if t != nil { if t != nil {
t.Commit() t.Commit()
} }
if coll != nil && app.cfg.App.Federation { if coll != nil && !app.cfg.App.Private && app.cfg.App.Federation {
go deleteFederatedPost(app, pp, collID.Int64) go deleteFederatedPost(app, pp, collID.Int64)
} }
@ -870,7 +870,7 @@ func addPost(app *App, w http.ResponseWriter, r *http.Request) error {
return err return err
} }
if app.cfg.App.Federation { if !app.cfg.App.Private && app.cfg.App.Federation {
for _, pRes := range *res { for _, pRes := range *res {
if pRes.Code != http.StatusOK { if pRes.Code != http.StatusOK {
continue continue

Loading…
Cancel
Save