Skip to content

Commit

Permalink
Merge pull request #24 from tapglue/remove-self-events
Browse files Browse the repository at this point in the history
Remove owners events from notification self feed
  • Loading branch information
xla authored Nov 30, 2016
2 parents 7a0c7cb + feef944 commit 3230ddb
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions core/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,9 @@ func FeedNotificationsSelf(
var (
fs = am.filterFollowings(origin)
sources = []source{
sourceComment(objects, currentApp, ps.IDs()...),
sourceComment(objects, currentApp, origin, ps.IDs()...),
sourceConnection(fs.connections(), opts),
sourceLikes(events, currentApp, opts, ps.IDs()...),
sourceLikes(events, currentApp, opts, origin, ps.IDs()...),
sourceTarget(events, currentApp, origin, opts),
}
)
Expand Down Expand Up @@ -973,6 +973,7 @@ func neighbours(
func sourceComment(
objects object.Service,
currentApp *app.App,
origin uint64,
postIDs ...uint64,
) source {
if len(postIDs) == 0 {
Expand All @@ -996,6 +997,10 @@ func sourceComment(
}

for _, comment := range cs {
if comment.OwnerID == origin {
continue
}

id, err := flake.NextID("comment-events")
if err != nil {
return nil, err
Expand Down Expand Up @@ -1100,6 +1105,7 @@ func sourceLikes(
events event.Service,
currentApp *app.App,
opts event.QueryOptions,
origin uint64,
postIDs ...uint64,
) source {
if len(postIDs) == 0 {
Expand All @@ -1116,7 +1122,22 @@ func sourceLikes(
}

return func() (event.List, error) {
return events.Query(currentApp.Namespace(), opts)
es, err := events.Query(currentApp.Namespace(), opts)
if err != nil {
return nil, err
}

fs := event.List{}

for _, e := range es {
if e.UserID == origin {
continue
}

fs = append(fs, e)
}

return fs, nil
}
}

Expand Down

0 comments on commit 3230ddb

Please sign in to comment.