From 8f5f077c318e9b466cc47ebab548ea0cd69052f0 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 27 Jun 2020 16:26:21 +0300 Subject: feat: only modify polls order for authorized users --- services/feed/feed.hooks.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'services/feed/feed.hooks.ts') diff --git a/services/feed/feed.hooks.ts b/services/feed/feed.hooks.ts index 0e201db..33c6e71 100644 --- a/services/feed/feed.hooks.ts +++ b/services/feed/feed.hooks.ts @@ -1,6 +1,7 @@ import _ from 'lodash'; import { HookContext } from '@feathersjs/feathers'; - +import { iff, combine } from 'feathers-hooks-common'; +import isAuthenticated from '../../hooks/isAuthenticated'; const raiseNewVerifedPolls = async (context: HookContext): Promise => { // Raise unseen verified polls to the very top @@ -22,7 +23,10 @@ const lowerOldPolls = async (context: HookContext): Promise => { export default { after: { - find: [raiseNewVerifedPolls, lowerOldPolls] + find: [ + iff(isAuthenticated, raiseNewVerifedPolls), + iff(isAuthenticated, lowerOldPolls), + ] } }; -- cgit v1.2.3