fix: updates since api returns error for android client if invalid date is supplied

This commit is contained in:
Hongbo Wu
2023-10-23 19:07:47 +08:00
parent e94a61a9bc
commit 27b352f9ae
2 changed files with 22 additions and 1 deletions

View File

@ -46,6 +46,7 @@ import {
TypeaheadSearchSuccess,
UpdateReason,
UpdatesSinceError,
UpdatesSinceErrorCode,
UpdatesSinceSuccess,
} from '../../generated/graphql'
import { getColumns } from '../../repository'
@ -702,7 +703,12 @@ export const updatesSinceResolver = authorized<
const startCursor = after || ''
const size = first || 10
const startDate = new Date(since)
let startDate = new Date(since)
if (isNaN(startDate.getTime())) {
// for android app compatibility
startDate = new Date(0)
}
const { libraryItems, count } = await searchLibraryItems(
{
from: Number(startCursor),

View File

@ -1670,6 +1670,21 @@ describe('Article API', () => {
UpdateReason.Deleted
)
})
context('when since is -1000000000-01-01T00:00:00Z from android app', () => {
before(() => {
since = '-1000000000-01-01T00:00:00Z'
})
it('returns all', async () => {
const res = await graphqlRequest(
updatesSinceQuery(since),
authToken
).expect(200)
expect(res.body.data.updatesSince.edges.length).to.eql(5)
})
})
})
describe('BulkAction API', () => {