diff --git a/packages/commonwealth/client/scripts/state/api/config.ts b/packages/commonwealth/client/scripts/state/api/config.ts index d41d3784189..0c6258a88aa 100644 --- a/packages/commonwealth/client/scripts/state/api/config.ts +++ b/packages/commonwealth/client/scripts/state/api/config.ts @@ -14,7 +14,6 @@ export const ApiEndpoints = { // stand alone endpoints should be have upper snake case keys so we can easily tell them apart in code FETCH_ADMIN: '/roles', FETCH_COMMUNITY_STAKES: '/communityStakes', - FETCH_COMMENTS: '/viewComments', FETCH_RELATED_COMMUNITIES: '/relatedCommunities', FETCH_THREADS: '/threads', FETCH_NODES: '/nodes', diff --git a/packages/commonwealth/server/routes/viewComments.ts b/packages/commonwealth/server/routes/viewComments.ts deleted file mode 100644 index 562171ca10f..00000000000 --- a/packages/commonwealth/server/routes/viewComments.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { AppError } from '@hicommonwealth/core'; -import type { DB } from '@hicommonwealth/model'; -import { sanitizeDeletedComment } from '@hicommonwealth/model'; -import type { NextFunction, Request, Response } from 'express'; - -export const Errors = { - NoRootId: 'Must provide thread_id', - InvalidId: 'Invalid thread_id', -}; - -const viewComments = async ( - models: DB, - req: Request, - res: Response, - next: NextFunction, -) => { - const { community } = req; - const threadId = req.query.thread_id as string; - - if (!threadId) { - return next(new AppError(Errors.NoRootId)); - } - - const parsedInt = parseInt(threadId, 10); - if (isNaN(parsedInt) || parsedInt !== parseFloat(threadId)) { - return next(new AppError(Errors.InvalidId)); - } - - const comments = await models.Comment.findAll({ - include: [ - { - model: models.Address, - include: [ - { - model: models.User, - as: 'User', - required: true, - attributes: ['id', 'profile'], - }, - ], - }, - { - model: models.Thread, - attributes: ['id'], - required: true, - where: { id: threadId, community_id: community!.id }, - }, - { - model: models.Reaction, - as: 'reactions', - include: [ - { - model: models.Address, - as: 'Address', - required: true, - attributes: ['address', 'last_active'], - include: [ - { - model: models.User, - as: 'User', - required: true, - attributes: ['id', 'profile'], - }, - ], - }, - ], - }, - { - model: models.CommentVersionHistory, - }, - ], - order: [['created_at', 'DESC']], - paranoid: false, - }); - - const sanitizedComments = comments.map((c) => { - const data = c.toJSON(); - return { - ...sanitizeDeletedComment(data), - last_edited: data.updated_at, - }; - }); - - return res.json({ - status: 'Success', - result: sanitizedComments, - }); -}; - -export default viewComments; diff --git a/packages/commonwealth/server/routing/router.ts b/packages/commonwealth/server/routing/router.ts index ecd54be0a23..3558220a8c4 100644 --- a/packages/commonwealth/server/routing/router.ts +++ b/packages/commonwealth/server/routing/router.ts @@ -26,7 +26,6 @@ import threadsUsersCountAndAvatars from '../routes/threadsUsersCountAndAvatars'; import updateBanner from '../routes/updateBanner'; import updateEmail from '../routes/updateEmail'; import updateSiteAdmin from '../routes/updateSiteAdmin'; -import viewComments from '../routes/viewComments'; import setDefaultRole from '../routes/setDefaultRole'; import upgradeMember, { @@ -316,13 +315,6 @@ function setupRouter( ); // comments - registerRoute( - router, - 'get', - '/viewComments', - databaseValidationService.validateCommunity, - viewComments.bind(this, models), - ); registerRoute( router, 'get',