Merge pull request #2359 from omnivore-app/fix/pocket-import
fix/pocket import
This commit is contained in:
@ -49,6 +49,7 @@
|
||||
"cookie": "^0.5.0",
|
||||
"cookie-parser": "^1.4.5",
|
||||
"cors": "^2.8.5",
|
||||
"csv-stringify": "^6.4.0",
|
||||
"dataloader": "^2.0.0",
|
||||
"diff-match-patch": "^1.0.5",
|
||||
"dompurify": "^2.0.17",
|
||||
@ -107,6 +108,7 @@
|
||||
"@types/chai-string": "^1.4.2",
|
||||
"@types/cookie": "^0.4.0",
|
||||
"@types/cookie-parser": "^1.4.2",
|
||||
"@types/csv-stringify": "^3.1.0",
|
||||
"@types/diff-match-patch": "^1.0.32",
|
||||
"@types/dompurify": "^2.0.4",
|
||||
"@types/express": "^4.17.7",
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-misused-promises */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
import { stringify } from 'csv-stringify'
|
||||
import express from 'express'
|
||||
import { DateTime } from 'luxon'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
@ -220,6 +221,12 @@ export function integrationsServiceRouter() {
|
||||
writeStream = file.createWriteStream({
|
||||
contentType: 'text/csv',
|
||||
})
|
||||
// stringify the data and pipe it to the write_stream
|
||||
const stringifier = stringify({
|
||||
header: false,
|
||||
columns: ['url', 'state', 'labels'],
|
||||
})
|
||||
stringifier.pipe(writeStream)
|
||||
|
||||
let hasMore = true
|
||||
let offset = 0
|
||||
@ -236,11 +243,7 @@ export function integrationsServiceRouter() {
|
||||
break
|
||||
}
|
||||
// write the list of urls, state and labels to the stream
|
||||
const csvData = retrievedData.map((page) => {
|
||||
const { url, state, labels } = page
|
||||
return [url, state, `"[${labels?.join(',') || ''}]"`].join(',')
|
||||
})
|
||||
writeStream.write(csvData.join('\n'))
|
||||
retrievedData.forEach((row) => stringifier.write(row))
|
||||
|
||||
hasMore = !!retrieved.hasMore
|
||||
offset += retrievedData.length
|
||||
|
||||
@ -369,8 +369,16 @@ describe('Integrations routers', () => {
|
||||
complete: 1,
|
||||
list: {
|
||||
'123': {
|
||||
given_url: 'https://omnivore.app/pocket-import-test',
|
||||
given_url: 'https://omnivore.app/pocket-import-test,test',
|
||||
state: '0',
|
||||
tags: {
|
||||
'1234': {
|
||||
tag: 'test',
|
||||
},
|
||||
'1235': {
|
||||
tag: 'new',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
since: Date.now() / 1000,
|
||||
@ -387,6 +395,7 @@ describe('Integrations routers', () => {
|
||||
|
||||
after(async () => {
|
||||
sinon.restore()
|
||||
nock.cleanAll()
|
||||
await deleteTestIntegrations(user.id, [integration.id])
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user