X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Futils.ts;h=b53a52a053f9e86276a2632a3185ef2665044832;hb=92e0f42e8ce5f1ab5e4023900b8194627231a11b;hp=ccdbcd1cf7d8a81eafebc5668152315f44003a2a;hpb=d7a25329f9e607894d29ab342b9cb66638b56dc0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/utils.ts b/server/models/utils.ts index ccdbcd1cf..b53a52a05 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts @@ -58,6 +58,19 @@ function getBlacklistSort (model: any, value: string, lastSort: OrderItem = [ 'i return [ firstSort, lastSort ] } +function getFollowsSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { + const { direction, field } = buildDirectionAndField(value) + + if (field === 'redundancyAllowed') { + return [ + [ 'ActorFollowing', 'Server', 'redundancyAllowed', direction ], + lastSort + ] + } + + return getSort(value, lastSort) +} + function isOutdated (model: { createdAt: Date, updatedAt: Date }, refreshInterval: number) { const now = Date.now() const createdAtTime = model.createdAt.getTime() @@ -163,6 +176,7 @@ export { buildWhereIdOrUUID, isOutdated, parseAggregateResult, + getFollowsSort, createSafeIn }