Skip to content

Commit

Permalink
Merge pull request #28 from tapglue/own-posts-feed
Browse files Browse the repository at this point in the history
Include own posts in post feed
  • Loading branch information
xla authored Dec 1, 2016
2 parents 8c92e66 + 91ff660 commit c1ac4bf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions core/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,13 @@ func FeedPosts(

ps = append(ps, gs...)

os, err := ownPosts(objects, currentApp, origin, opts)
if err != nil {
return nil, err
}

ps = append(ps, os...)

sort.Sort(ps)

if len(ps) > opts.Limit {
Expand Down Expand Up @@ -971,6 +978,34 @@ func neighbours(
return am, nil
}

func ownPosts(
objects object.Service,
currentApp *app.App,
origin uint64,
opts object.QueryOptions,
) (PostList, error) {
opts.OwnerIDs = []uint64{
origin,
}
opts.Owned = &defaultOwned
opts.Types = []string{
TypePost,
}
opts.Visibilities = []object.Visibility{
object.VisibilityPrivate,
object.VisibilityConnection,
object.VisibilityPublic,
object.VisibilityGlobal,
}

os, err := objects.Query(currentApp.Namespace(), opts)
if err != nil {
return nil, err
}

return postsFromObjects(os), nil
}

// sourceComment creates comment events for the given posts.
func sourceComment(
objects object.Service,
Expand Down

0 comments on commit c1ac4bf

Please sign in to comment.