Thanks, that works perfectly. I'm handling the hook in my custom theme, but this probably needs to be in the https://community.nodebb.org/post/95161 plugin as well (without the importedVotes)
library.setTopicVotes = async function(hookData) { const topicData = await topics.getTopicFields(hookData.post.tid, ['cid', 'importedVotes']); const importedVotes = topicData.importedVotes || 0 const voteData = await db.getSortedSetRangeByScoreWithScores(`tid:${hookData.post.tid}:posts:votes`, 0, -1, 1, '+inf'); let allvotes = voteData.reduce((acc, cur) => acc + cur.score, 0); allvotes = allvotes + importedVotes await db.sortedSetAdd(`cid:${topicData.cid}:tids:votes`, allvotes, hookData.post.tid) }How to stop the posting process in a client side script
Unsolved
Technical Support
-
I wrote a small client-side script, which checks
$('write').val()
on a regular expression, and if it contains certain words, displays a recommendation to the user to avoid them.
The script is activated by clicking on the post button of the post / topic.
The question is is it possible to stop the publication of the post along with the presentation of the recommendation (I present the recommendation via app.alert)? Let there be a recommendation, and the post not be published? I want something on the client side, not a server side extension
Thank you!