mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: move filter:topic.post hook to top of method
This commit is contained in:
@@ -76,7 +76,8 @@ module.exports = function (Topics) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Topics.post = async function (data) {
|
Topics.post = async function (data) {
|
||||||
let { uid } = data;
|
data = await plugins.hooks.fire('filter:topic.post', data);
|
||||||
|
|
||||||
data.title = String(data.title).trim();
|
data.title = String(data.title).trim();
|
||||||
data.tags = data.tags || [];
|
data.tags = data.tags || [];
|
||||||
if (data.content) {
|
if (data.content) {
|
||||||
@@ -89,8 +90,8 @@ module.exports = function (Topics) {
|
|||||||
|
|
||||||
const [categoryExists, canCreate, canTag] = await Promise.all([
|
const [categoryExists, canCreate, canTag] = await Promise.all([
|
||||||
categories.exists(data.cid),
|
categories.exists(data.cid),
|
||||||
privileges.categories.can('topics:create', data.cid, data.uid),
|
privileges.categories.can('topics:create', data.cid, uid),
|
||||||
privileges.categories.can('topics:tag', data.cid, data.uid),
|
privileges.categories.can('topics:tag', data.cid, uid),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!categoryExists) {
|
if (!categoryExists) {
|
||||||
@@ -103,11 +104,9 @@ module.exports = function (Topics) {
|
|||||||
|
|
||||||
await guestHandleValid(data);
|
await guestHandleValid(data);
|
||||||
if (!data.fromQueue) {
|
if (!data.fromQueue) {
|
||||||
await user.isReadyToPost(data.uid, data.cid);
|
await user.isReadyToPost(uid, data.cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
data = await plugins.hooks.fire('filter:topic.post', data);
|
|
||||||
({ uid } = data); // uid was explicitly destructured at top, so update if changed
|
|
||||||
const tid = await Topics.create(data);
|
const tid = await Topics.create(data);
|
||||||
|
|
||||||
let postData = data;
|
let postData = data;
|
||||||
|
|||||||
Reference in New Issue
Block a user