diff --git a/apps/juxtaposition-ui/src/database.js b/apps/juxtaposition-ui/src/database.js index a9d522d0..fc2eddf5 100644 --- a/apps/juxtaposition-ui/src/database.js +++ b/apps/juxtaposition-ui/src/database.js @@ -34,6 +34,10 @@ function verifyConnected() { } } +export function notBanned() { + return { account_status: { $in: [0, 1] } }; +} + async function getCommunities(numberOfCommunities, offset) { verifyConnected(); if (!offset) { @@ -288,7 +292,8 @@ async function getUserContent(pid) { async function getFollowingUsers(content) { verifyConnected(); return SETTINGS.find({ - pid: content.following_users + pid: content.following_users, + ...notBanned() }); } diff --git a/apps/juxtaposition-ui/src/services/juxt-web/routes/console/feed.tsx b/apps/juxtaposition-ui/src/services/juxt-web/routes/console/feed.tsx index f32b201a..7affcff4 100644 --- a/apps/juxtaposition-ui/src/services/juxt-web/routes/console/feed.tsx +++ b/apps/juxtaposition-ui/src/services/juxt-web/routes/console/feed.tsx @@ -3,7 +3,7 @@ import { z } from 'zod'; import { database } from '@/database'; import { POST } from '@/models/post'; import { config } from '@/config'; -import { parseReq } from '@/services/juxt-web/routes/routeUtils'; +import { ifNotMod, parseReq } from '@/services/juxt-web/routes/routeUtils'; import { WebGlobalFeedView, WebPersonalFeedView } from '@/services/juxt-web/views/web/feed'; import { buildContext } from '@/services/juxt-web/views/context'; import { WebPostListView } from '@/services/juxt-web/views/web/postList'; @@ -54,10 +54,13 @@ feedRouter.get('/all', async function (req, res) { if (!userContent) { return res.redirect('/404'); } + const posts = await POST.find({ - parent: null, - message_to_pid: null, - removed: false + ...ifNotMod(res, { + parent: null, + removed: false + }), + message_to_pid: null }).limit(config.postLimit).sort({ created_at: -1 }); const nextLink = `/feed/all/more?offset=${posts.length}&pjax=true`; @@ -117,9 +120,11 @@ feedRouter.get('/all/more', async function (req, res) { } const posts = await POST.find({ - parent: null, - message_to_pid: null, - removed: false + ...ifNotMod(res, { + parent: null, + removed: false + }), + message_to_pid: null }).skip(query.offset).limit(config.postLimit).sort({ created_at: -1 }); const nextLink = `/feed/all/more?offset=${query.offset + posts.length}&pjax=true`; diff --git a/apps/juxtaposition-ui/src/services/juxt-web/routes/routeUtils.ts b/apps/juxtaposition-ui/src/services/juxt-web/routes/routeUtils.ts index a23cbeb0..071165d3 100644 --- a/apps/juxtaposition-ui/src/services/juxt-web/routes/routeUtils.ts +++ b/apps/juxtaposition-ui/src/services/juxt-web/routes/routeUtils.ts @@ -1,5 +1,5 @@ import type { GetUserDataResponse as AccountGetUserDataResponse } from '@pretendonetwork/grpc/account/get_user_data_rpc'; -import type { Request } from 'express'; +import type { Request, Response } from 'express'; import type { z } from 'zod'; import type { UserTokens } from '@/types/juxt/tokens'; import type { ParamPack } from '@/types/common/param-pack'; @@ -107,3 +107,13 @@ export function parseReq; } + +/** + * Returns a Mongoose filter if the account isn't a moderator. + */ +export function ifNotMod(res: Response, filter: T): T | {} { + if (res.locals.moderator) { + return {}; + } + return filter; +} diff --git a/apps/juxtaposition-ui/src/services/juxt-web/views/web/post.tsx b/apps/juxtaposition-ui/src/services/juxt-web/views/web/post.tsx index 5766c945..9dc429f0 100644 --- a/apps/juxtaposition-ui/src/services/juxt-web/views/web/post.tsx +++ b/apps/juxtaposition-ui/src/services/juxt-web/views/web/post.tsx @@ -54,7 +54,7 @@ export function WebPostView(props: PostViewProps): ReactNode { : null}

- {moment(post.created_at).fromNow()} + {moment(post.created_at).fromNow()} {' - '} {props.ctx.communityMap.get(post.community_id ?? '')}