File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,16 @@ export default defineEventHandler(async (event): Promise<boolean | Error> => {
1414 return createError ( { statusCode : 422 , statusMessage : 'Invalid request' } ) ;
1515 }
1616
17+ const data = { ...body . data } ;
18+ if ( data . viewKeywords . length > 0 && ! data . viewKeywords . includes ( data . keyword ) ) {
19+ const commonKeywords = data . keywords . filter ( ( kw ) => data . viewKeywords . includes ( kw ) ) ;
20+ if ( commonKeywords . length > 0 ) {
21+ data . keyword = commonKeywords [ 0 ] ;
22+ }
23+ }
24+
1725 await addDataToTinybirdDatasource ( 'mentions' , {
18- ...body . data ,
26+ ...data ,
1927 projectSlug : slug ,
2028 } ) ;
2129 return true ;
Original file line number Diff line number Diff line change @@ -13,10 +13,12 @@ export interface CommunityMentionsData {
1313 relevanceScore : string ;
1414 relevanceComment : string ;
1515 keyword : string ;
16+ keywords : string [ ] ;
1617 sentimentLabel : string ;
1718 subreddit ?: string ;
1819 viewId : string ;
1920 viewName : string ;
21+ viewKeywords : string [ ] ;
2022}
2123export interface OctolensWebhook {
2224 action : string ;
You can’t perform that action at this time.
0 commit comments