mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Update subscriptions query
This commit is contained in:
parent
9b181633d9
commit
3565c7000e
2 changed files with 12 additions and 11 deletions
|
|
@ -31,6 +31,7 @@ import { Merge } from '../../util'
|
|||
import { analytics } from '../../utils/analytics'
|
||||
import { enqueueRssFeedFetch } from '../../utils/createTask'
|
||||
import { authorized } from '../../utils/helpers'
|
||||
import { Brackets } from 'typeorm'
|
||||
|
||||
type PartialSubscription = Omit<Subscription, 'newsletterEmail'>
|
||||
|
||||
|
|
@ -76,20 +77,21 @@ export const subscriptionsResolver = authorized<
|
|||
user: { id: uid },
|
||||
})
|
||||
|
||||
// Show all RSS, but only active newsletters
|
||||
queryBuilder
|
||||
.andWhere({
|
||||
type: SubscriptionType.Newsletter,
|
||||
status: SubscriptionStatus.Active,
|
||||
})
|
||||
.orWhere({
|
||||
type: SubscriptionType.Rss,
|
||||
})
|
||||
|
||||
if (type) {
|
||||
queryBuilder.andWhere({
|
||||
type,
|
||||
})
|
||||
} else {
|
||||
queryBuilder.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where({
|
||||
type: SubscriptionType.Newsletter,
|
||||
status: SubscriptionStatus.Active,
|
||||
}).orWhere({
|
||||
type: SubscriptionType.Rss,
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
const subscriptions = await queryBuilder
|
||||
|
|
|
|||
|
|
@ -166,7 +166,6 @@ describe('Subscriptions API', () => {
|
|||
SubscriptionType.Rss
|
||||
)
|
||||
const res = await graphqlRequest(query, authToken).expect(200)
|
||||
|
||||
expect(res.body.data.subscriptions.subscriptions).to.eql(
|
||||
subscriptions.map((sub) => ({
|
||||
id: sub.id,
|
||||
|
|
|
|||
Loading…
Reference in a new issue