mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
fix trigger
This commit is contained in:
parent
0e7f45a758
commit
463231b26b
1 changed files with 15 additions and 7 deletions
|
|
@ -2,7 +2,7 @@ import { nanoid } from 'nanoid'
|
|||
import { DeepPartial } from 'typeorm'
|
||||
import { LibraryItem } from '../entity/library_item'
|
||||
import { Recommendation } from '../entity/recommendation'
|
||||
import { getRepository } from '../repository'
|
||||
import { authTrx, getRepository } from '../repository'
|
||||
import { logger } from '../utils/logger'
|
||||
import { createHighlights } from './highlights'
|
||||
import { createLibraryItem, findLibraryItemByUrl } from './library_item'
|
||||
|
|
@ -62,10 +62,13 @@ export const addRecommendation = async (
|
|||
await createHighlights(highlights, recommendedItem.id, userId)
|
||||
}
|
||||
|
||||
await createRecommendation({
|
||||
...recommendation,
|
||||
libraryItem: { id: recommendedItem.id },
|
||||
})
|
||||
await createRecommendation(
|
||||
{
|
||||
...recommendation,
|
||||
libraryItem: { id: recommendedItem.id },
|
||||
},
|
||||
userId
|
||||
)
|
||||
|
||||
return recommendedItem
|
||||
} catch (err) {
|
||||
|
|
@ -75,9 +78,14 @@ export const addRecommendation = async (
|
|||
}
|
||||
|
||||
export const createRecommendation = async (
|
||||
recommendation: DeepPartial<Recommendation>
|
||||
recommendation: DeepPartial<Recommendation>,
|
||||
userId: string
|
||||
) => {
|
||||
return getRepository(Recommendation).save(recommendation)
|
||||
return authTrx(
|
||||
async (tx) => tx.getRepository(Recommendation).save(recommendation),
|
||||
undefined,
|
||||
userId
|
||||
)
|
||||
}
|
||||
|
||||
export const findRecommendationsByLibraryItemId = async (
|
||||
|
|
|
|||
Loading…
Reference in a new issue