Merge pull request #1536 from omnivore-app/fix/recent-search

Do not save recent searches for rule based queries
This commit is contained in:
Hongbo Wu 2022-12-12 20:52:34 +08:00 committed by GitHub
commit bbecb4f2f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -98,6 +98,7 @@ import {
import { searchHighlights } from '../../elastic/highlights'
import { saveSearchHistory } from '../../services/search_history'
import { parsedContentToPage } from '../../services/save_page'
import * as httpContext from 'express-http-context'
export type PartialArticle = Omit<
Article,
@ -908,7 +909,10 @@ export const searchResolver = authorized<
// save query, including advanced search terms, in search history
if (params.query) {
await saveSearchHistory(claims.uid, params.query)
const client = httpContext.get('client') as string | undefined
// don't save search history for rule based queries
client !== 'rule-handler' &&
(await saveSearchHistory(claims.uid, params.query))
}
return {

View file

@ -66,6 +66,7 @@ export const search = async (
headers: {
Cookie: `auth=${auth};`,
'Content-Type': 'application/json',
'X-OmnivoreClient': 'rule-handler',
},
}
)