aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/actor/actor-follow.ts26
-rw-r--r--server/models/video/sql/videos-id-list-query-builder.ts6
2 files changed, 15 insertions, 17 deletions
diff --git a/server/models/actor/actor-follow.ts b/server/models/actor/actor-follow.ts
index 3a09e51d6..83c00a22d 100644
--- a/server/models/actor/actor-follow.ts
+++ b/server/models/actor/actor-follow.ts
@@ -324,13 +324,13 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
324 324
325 const followWhere = state ? { state } : {} 325 const followWhere = state ? { state } : {}
326 const followingWhere: WhereOptions = {} 326 const followingWhere: WhereOptions = {}
327 const followingServerWhere: WhereOptions = {}
328 327
329 if (search) { 328 if (search) {
330 Object.assign(followingServerWhere, { 329 Object.assign(followWhere, {
331 host: { 330 [Op.or]: [
332 [Op.iLike]: '%' + search + '%' 331 searchAttribute(options.search, '$ActorFollowing.preferredUsername$'),
333 } 332 searchAttribute(options.search, '$ActorFollowing.Server.host$')
333 ]
334 }) 334 })
335 } 335 }
336 336
@@ -361,8 +361,7 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
361 include: [ 361 include: [
362 { 362 {
363 model: ServerModel, 363 model: ServerModel,
364 required: true, 364 required: true
365 where: followingServerWhere
366 } 365 }
367 ] 366 ]
368 } 367 }
@@ -391,13 +390,13 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
391 390
392 const followWhere = state ? { state } : {} 391 const followWhere = state ? { state } : {}
393 const followerWhere: WhereOptions = {} 392 const followerWhere: WhereOptions = {}
394 const followerServerWhere: WhereOptions = {}
395 393
396 if (search) { 394 if (search) {
397 Object.assign(followerServerWhere, { 395 Object.assign(followWhere, {
398 host: { 396 [Op.or]: [
399 [Op.iLike]: '%' + search + '%' 397 searchAttribute(search, '$ActorFollower.preferredUsername$'),
400 } 398 searchAttribute(search, '$ActorFollower.Server.host$')
399 ]
401 }) 400 })
402 } 401 }
403 402
@@ -420,8 +419,7 @@ export class ActorFollowModel extends Model<Partial<AttributesOnly<ActorFollowMo
420 include: [ 419 include: [
421 { 420 {
422 model: ServerModel, 421 model: ServerModel,
423 required: true, 422 required: true
424 where: followerServerWhere
425 } 423 }
426 ] 424 ]
427 }, 425 },
diff --git a/server/models/video/sql/videos-id-list-query-builder.ts b/server/models/video/sql/videos-id-list-query-builder.ts
index 30b251f0f..054f71c8c 100644
--- a/server/models/video/sql/videos-id-list-query-builder.ts
+++ b/server/models/video/sql/videos-id-list-query-builder.ts
@@ -304,16 +304,16 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder {
304 private whereFollowerActorId (followerActorId: number, includeLocalVideos: boolean) { 304 private whereFollowerActorId (followerActorId: number, includeLocalVideos: boolean) {
305 let query = 305 let query =
306 '(' + 306 '(' +
307 ' EXISTS (' + 307 ' EXISTS (' + // Videos shared by actors we follow
308 ' SELECT 1 FROM "videoShare" ' + 308 ' SELECT 1 FROM "videoShare" ' +
309 ' INNER JOIN "actorFollow" "actorFollowShare" ON "actorFollowShare"."targetActorId" = "videoShare"."actorId" ' + 309 ' INNER JOIN "actorFollow" "actorFollowShare" ON "actorFollowShare"."targetActorId" = "videoShare"."actorId" ' +
310 ' AND "actorFollowShare"."actorId" = :followerActorId AND "actorFollowShare"."state" = \'accepted\' ' + 310 ' AND "actorFollowShare"."actorId" = :followerActorId AND "actorFollowShare"."state" = \'accepted\' ' +
311 ' WHERE "videoShare"."videoId" = "video"."id"' + 311 ' WHERE "videoShare"."videoId" = "video"."id"' +
312 ' )' + 312 ' )' +
313 ' OR' + 313 ' OR' +
314 ' EXISTS (' + 314 ' EXISTS (' + // Videos published by accounts we follow
315 ' SELECT 1 from "actorFollow" ' + 315 ' SELECT 1 from "actorFollow" ' +
316 ' WHERE "actorFollow"."targetActorId" = "videoChannel"."actorId" AND "actorFollow"."actorId" = :followerActorId ' + 316 ' WHERE "actorFollow"."targetActorId" = "account"."actorId" AND "actorFollow"."actorId" = :followerActorId ' +
317 ' AND "actorFollow"."state" = \'accepted\'' + 317 ' AND "actorFollow"."state" = \'accepted\'' +
318 ' )' 318 ' )'
319 319