1+ import { In } from 'typeorm' ;
12import { AppDataSourceRead , AppDataSourceReadWrite } from '@orm/db' ;
23import { Feed } from '@orm/entities/feed/feed' ;
34import { FeedFlagStatusStatusEnum } from '@orm/entities/feed/feedFlagStatus' ;
@@ -48,6 +49,32 @@ export class FeedService {
4849 } ) ;
4950 }
5051
52+ async getByUrl ( url : string ) : Promise < Feed | null > {
53+ const base = url . replace ( / ^ h t t p s ? : \/ \/ / i, '' ) ;
54+ const httpsUrl = `https://${ base } ` ;
55+ const httpUrl = `http://${ base } ` ;
56+
57+ const httpsFeed = await this . repositoryRead . findOne ( {
58+ where : {
59+ url : httpsUrl ,
60+ feed_flag_status : In ( [ FeedFlagStatusStatusEnum . Active , FeedFlagStatusStatusEnum . AlwaysParse ] )
61+ } ,
62+ relations : [ 'channel' , 'feed_flag_status' , 'feed_log' ] ,
63+ } ) ;
64+ if ( httpsFeed ) return httpsFeed ;
65+
66+ const httpFeed = await this . repositoryRead . findOne ( {
67+ where : {
68+ url : httpUrl ,
69+ feed_flag_status : In ( [ FeedFlagStatusStatusEnum . Active , FeedFlagStatusStatusEnum . AlwaysParse ] )
70+ } ,
71+ relations : [ 'channel' , 'feed_flag_status' , 'feed_log' ] ,
72+ } ) ;
73+ if ( httpFeed ) return httpFeed ;
74+
75+ return null ;
76+ }
77+
5178 async getByUrlAndPodcastIndexId ( { url, podcast_index_id } : { url : string , podcast_index_id : number } ) : Promise < Feed | null > {
5279 return this . repositoryRead . findOne ( {
5380 where : {
@@ -65,7 +92,8 @@ export class FeedService {
6592 where : {
6693 channel : {
6794 podcast_index_id
68- }
95+ } ,
96+ feed_flag_status : In ( [ FeedFlagStatusStatusEnum . Active , FeedFlagStatusStatusEnum . AlwaysParse ] )
6997 } ,
7098 relations : [ 'channel' , 'feed_flag_status' , 'feed_log' ] ,
7199 } ) ;
0 commit comments