Skip to content

Commit

Permalink
Refactored lines 107-113 and test ran successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
AlAnoud2003 committed Sep 2, 2024
1 parent 883bd38 commit 2edd414
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/topics/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,17 @@ module.exports = function (Topics) {

// Check if the category exists
if (!categoryExists) {
throw new Error('[[error:no-category]]');
throw new Error('[[error:no-category]]');
}

// Check if the user has the necessary privileges to create or tag
const cannotCreate = !canCreate;
const cannotTag = !canTag && data.tags.length;

if (cannotCreate || cannotTag) {
throw new Error('[[error:no-privileges]]');
throw new Error('[[error:no-privileges]]');
}










await guestHandleValid(data);
if (!data.fromQueue) {
await user.isReadyToPost(uid, data.cid);
Expand Down Expand Up @@ -332,4 +323,4 @@ module.exports = function (Topics) {
throw new Error('[[error:no-privileges]]');
}
}
};
};

0 comments on commit 2edd414

Please sign in to comment.