diff --git a/libs/model/src/comment/UpdateComment.command.ts b/libs/model/src/comment/UpdateComment.command.ts index d7033940731..c2fa679205a 100644 --- a/libs/model/src/comment/UpdateComment.command.ts +++ b/libs/model/src/comment/UpdateComment.command.ts @@ -3,6 +3,7 @@ import * as schemas from '@hicommonwealth/schemas'; import { models } from '../database'; import { isAuthorized, type AuthContext } from '../middleware'; import { mustBeAuthorized } from '../middleware/guards'; +import { getCommentSearchVector } from '../models'; import { emitMentions, findMentionDiff, @@ -47,7 +48,7 @@ export function UpdateComment(): Command< // == mutation transaction boundary == await models.sequelize.transaction(async (transaction) => { await models.Comment.update( - { text, plaintext }, + { text, plaintext, search: getCommentSearchVector(text) }, { where: { id: comment.id }, transaction }, ); diff --git a/packages/commonwealth/server/controllers/server_threads_methods/update_thread.ts b/packages/commonwealth/server/controllers/server_threads_methods/update_thread.ts index eca7e1144f8..338cd8aacd3 100644 --- a/packages/commonwealth/server/controllers/server_threads_methods/update_thread.ts +++ b/packages/commonwealth/server/controllers/server_threads_methods/update_thread.ts @@ -9,6 +9,7 @@ import { UserInstance, emitMentions, findMentionDiff, + getThreadSearchVector, parseUserMentions, } from '@hicommonwealth/model'; import { renderQuillDeltaToText } from '@hicommonwealth/shared'; @@ -114,11 +115,12 @@ export async function __updateThread( // check if thread is part of a contest topic const contestManagers = await this.models.sequelize.query( ` - SELECT cm.contest_address FROM "Threads" t - JOIN "ContestTopics" ct on ct.topic_id = t.topic_id - JOIN "ContestManagers" cm on cm.contest_address = ct.contest_address - WHERE t.id = :thread_id - `, + SELECT cm.contest_address + FROM "Threads" t + JOIN "ContestTopics" ct on ct.topic_id = t.topic_id + JOIN "ContestManagers" cm on cm.contest_address = ct.contest_address + WHERE t.id = :thread_id + `, { type: QueryTypes.SELECT, replacements: { @@ -225,6 +227,7 @@ export async function __updateThread( await thread.update( { ...toUpdate, + search: getThreadSearchVector(title || thread.title, body), last_edited: Sequelize.literal('CURRENT_TIMESTAMP'), }, { transaction },