Skip to content

Commit

Permalink
cherrypicking support for browsable subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Apr 27, 2021
1 parent c009b44 commit b3daba7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions server/db/mongodb/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1285,9 +1285,9 @@ func (a *adapter) TopicsForUser(uid t.Uid, keepDeleted bool, opts *t.QueryOpt) (
}
limit := a.maxResults
if opts != nil {
// Ignore IfModifiedSince - we must return all entries
// Those unmodified will be stripped of Public & Private.

if opts.IfModifiedSince != nil {
filter["updatedat"] = b.M{"$gt": opts.IfModifiedSince}
}
if opts.Topic != "" {
filter["topic"] = opts.Topic
}
Expand Down
11 changes: 6 additions & 5 deletions server/db/mysql/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1428,9 +1428,10 @@ func (a *adapter) TopicsForUser(uid t.Uid, keepDeleted bool, opts *t.QueryOpt) (

limit := a.maxResults
if opts != nil {
// Ignore IfModifiedSince - we must return all entries
// Those unmodified will be stripped of Public & Private.

if opts.IfModifiedSince != nil {
q += " AND updatedat>?"
args = append(args, opts.IfModifiedSince)
}
if opts.Topic != "" {
q += " AND topic=?"
args = append(args, opts.Topic)
Expand Down Expand Up @@ -1597,7 +1598,7 @@ func (a *adapter) TopicsForUser(uid t.Uid, keepDeleted bool, opts *t.QueryOpt) (
}

// UsersForTopic loads users subscribed to the given topic.
// The difference between UsersForTopic vs SubsForTopic is that the former loads user.public,
// The difference between UsersForTopic vs SubsForTopic is that the former loads user.Public,
// the latter does not.
func (a *adapter) UsersForTopic(topic string, keepDeleted bool, opts *t.QueryOpt) ([]t.Subscription, error) {
tcat := t.GetTopicCat(topic)
Expand All @@ -1624,7 +1625,7 @@ func (a *adapter) UsersForTopic(topic string, keepDeleted bool, opts *t.QueryOpt
limit := a.maxResults
var oneUser t.Uid
if opts != nil {
// Ignore IfModifiedSince - we must return all entries
// Ignore IfModifiedSince: loading all entries because a topic cannot have too many subscribers.
// Those unmodified will be stripped of Public & Private.

if !opts.User.IsZero() {
Expand Down
6 changes: 3 additions & 3 deletions server/db/rethinkdb/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,9 +1091,9 @@ func (a *adapter) TopicsForUser(uid t.Uid, keepDeleted bool, opts *t.QueryOpt) (
}
limit := a.maxResults
if opts != nil {
// Ignore IfModifiedSince - we must return all entries
// Those unmodified will be stripped of Public & Private.

if opts.IfModifiedSince != nil {
q = q.Filter(rdb.Row.Field("UpdatedAt").Gt(opts.IfModifiedSince))
}
if opts.Topic != "" {
q = q.Filter(rdb.Row.Field("Topic").Eq(opts.Topic))
}
Expand Down

0 comments on commit b3daba7

Please sign in to comment.