Browse Source

Federate draft when published to a blog

This now sends out a `Create` activity when a post is moved from a draft
to a blog.

This closes #9. Closes T526.
pull/29/head
Matt Baer 5 years ago
parent
commit
8e6d0daa06
2 changed files with 13 additions and 1 deletions
  1. +4
    -1
      database.go
  2. +9
    -0
      posts.go

+ 4
- 1
database.go View File

@@ -1278,6 +1278,7 @@ func (db *datastore) ClaimPosts(userID int64, collAlias string, posts *[]ClaimPo
var query string
var params []interface{}
var slugIdx int = -1
var coll *Collection
if collAlias == "" {
// Posts are being claimed at /posts/claim, not
// /collections/{alias}/collect, so use given individual collection
@@ -1286,7 +1287,6 @@ func (db *datastore) ClaimPosts(userID int64, collAlias string, posts *[]ClaimPo
}
if postCollAlias != "" {
// Associate this post with a collection
var coll *Collection
if p.CreateCollection {
// This is a new collection
// TODO: consider removing this. This seriously complicates this
@@ -1389,6 +1389,9 @@ func (db *datastore) ClaimPosts(userID int64, collAlias string, posts *[]ClaimPo
// Post was successfully claimed
r.Code = http.StatusOK
r.Post = fullPost
if coll != nil {
r.Post.Collection = &CollectionObj{Collection: *coll}
}

rowsAffected, _ := qRes.RowsAffected()
if rowsAffected == 0 {


+ 9
- 0
posts.go View File

@@ -848,6 +848,15 @@ func addPost(app *app, w http.ResponseWriter, r *http.Request) error {
if err != nil {
return err
}

if app.cfg.App.Federation {
for _, pRes := range *res {
if pRes.Code != http.StatusOK {
continue
}
go federatePost(app, pRes.Post, pRes.Post.Collection.ID, false)
}
}
return impart.WriteSuccess(w, res, http.StatusOK)
}



Loading…
Cancel
Save