@@ -100,17 +100,21 @@ exports.crawlSite = async function (archive, crawlSource) {
100100 } )
101101}
102102
103- exports . list = async function ( { offset, limit, reverse, author} = { } ) {
103+ exports . list = async function ( { offset, limit, reverse, author, authors } = { } ) {
104104 // validate & parse params
105105 assert ( ! offset || typeof offset === 'number' , 'Offset must be a number' )
106106 assert ( ! limit || typeof limit === 'number' , 'Limit must be a number' )
107107 assert ( ! reverse || typeof reverse === 'boolean' , 'Reverse must be a boolean' )
108- assert ( ! author || typeof author === 'string' || ( Array . isArray ( author ) && author . every ( isString ) ) , 'Author must be a string or an array of strings' )
108+ assert ( ! author || typeof author === 'string' , 'Author must be a string' )
109+ assert ( ! authors || ( Array . isArray ( authors ) && authors . every ( isString ) ) , 'Authors must be an array of strings' )
109110
110111 if ( author ) {
111- author = Array . isArray ( author ) ? author : [ author ]
112- try { author = author . map ( toOrigin ) }
113- catch ( e ) { throw new Error ( 'Author must contain valid URLs' ) }
112+ authors = authors || [ ]
113+ authors . push ( author )
114+ }
115+ if ( authors ) {
116+ try { authors = authors . map ( toOrigin ) }
117+ catch ( e ) { throw new Error ( 'Author/authors must contain valid URLs' ) }
114118 }
115119
116120 // build query
@@ -119,9 +123,9 @@ exports.list = async function ({offset, limit, reverse, author} = {}) {
119123 INNER JOIN crawl_sources src ON src.id = crawl_posts.crawlSourceId
120124 `
121125 var values = [ ]
122- if ( author ) {
126+ if ( authors ) {
123127 let op = 'WHERE'
124- for ( let a of author ) {
128+ for ( let a of authors ) {
125129 query += ` ${ op } src.url = ?`
126130 op = 'OR'
127131 values . push ( a )
0 commit comments