mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Set labels = undefined if pocket tags is undefined
This commit is contained in:
parent
2423bff11c
commit
e14080a05f
4 changed files with 9 additions and 7 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import axios from 'axios'
|
||||
import { ArticleSavingRequestStatus } from '../../elastic/types'
|
||||
import { env } from '../../env'
|
||||
import {
|
||||
IntegrationService,
|
||||
RetrievedResult,
|
||||
RetrieveRequest,
|
||||
} from './integration'
|
||||
import axios from 'axios'
|
||||
import { env } from '../../env'
|
||||
import { ArticleSavingRequestStatus } from '../../elastic/types'
|
||||
|
||||
interface PocketResponse {
|
||||
status: number // 1 if success
|
||||
|
|
@ -130,7 +130,9 @@ export class PocketIntegration extends IntegrationService {
|
|||
}
|
||||
const data = pocketItems.map((item) => ({
|
||||
url: item.given_url,
|
||||
labels: Object.values(item.tags ?? {}).map((tag) => tag.tag),
|
||||
labels: item.tags
|
||||
? Object.values(item.tags).map((tag) => tag.tag)
|
||||
: undefined,
|
||||
state: statusToState[item.status],
|
||||
}))
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export const importCsv = async (ctx: ImportContext, stream: Stream) => {
|
|||
try {
|
||||
const url = new URL(row[0])
|
||||
const state = row.length > 1 ? row[1] : undefined
|
||||
// labels follows format: "[label1,label2]" or "[]"
|
||||
// labels follows format: "[label1,label2]"
|
||||
const labels =
|
||||
row.length > 2
|
||||
? (row[2] as string)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ describe('Load a complex CSV file', () => {
|
|||
{
|
||||
url: new URL('https://test.com'),
|
||||
state: 'SUCCEEDED',
|
||||
labels: [],
|
||||
labels: ['test', 'development'],
|
||||
},
|
||||
])
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
"https://omnivore.app",ARCHIVED,"[test]"
|
||||
"https://google.com",SUCCEEDED,"[test,development]"
|
||||
https://test.com,SUCCEEDED,"[]"
|
||||
https://test.com,SUCCEEDED,"[test, development]"
|
||||
|
|
|
|||
|
Loading…
Reference in a new issue