Add ability to search on domain and username too
authorChocobozzz <me@florianbigard.com>
Tue, 27 Mar 2018 13:09:53 +0000 (15:09 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 27 Mar 2018 13:09:53 +0000 (15:09 +0200)
server/models/video/video.ts

index 3611eca8900fa1b513c430f3216e44b26ea7ac1c..a28b5209b56a1fba95af02afbbadfe354f17e82c 100644 (file)
@@ -676,9 +676,23 @@ export class VideoModel extends Model<VideoModel> {
       limit: count,
       order: getSort(sort),
       where: {
-        name: {
-          [Sequelize.Op.iLike]: '%' + value + '%'
-        }
+        [Sequelize.Op.or]: [
+          {
+            name: {
+              [ Sequelize.Op.iLike ]: '%' + value + '%'
+            }
+          },
+          {
+            preferredUsername: Sequelize.where(Sequelize.col('preferredUsername'), {
+              [ Sequelize.Op.iLike ]: '%' + value + '%'
+            })
+          },
+          {
+            host: Sequelize.where(Sequelize.col('host'), {
+              [ Sequelize.Op.iLike ]: '%' + value + '%'
+            })
+          }
+        ]
       }
     }