summaryrefslogtreecommitdiff
path: root/lib/web
diff options
context:
space:
mode:
Diffstat (limited to 'lib/web')
-rw-r--r--lib/web/note/util.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/web/note/util.js b/lib/web/note/util.js
index effeb41c..dbca5d8e 100644
--- a/lib/web/note/util.js
+++ b/lib/web/note/util.js
@@ -46,7 +46,7 @@ exports.checkViewPermission = function (req, note) {
}
}
-exports.newNote = function (req, res, body) {
+exports.newNote = async function (req, res, body) {
let owner = null
const noteId = req.params.noteId ? req.params.noteId : null
if (req.isAuthenticated()) {
@@ -60,6 +60,19 @@ exports.newNote = function (req, res, body) {
} else {
return req.method === 'POST' ? errors.errorForbidden(res) : errors.errorNotFound(res)
}
+ try {
+ const count = await models.Note.count({
+ where: {
+ alias: req.alias
+ }
+ })
+ if (count > 0) {
+ return errors.errorConflict(res)
+ }
+ } catch (err) {
+ logger.error(err)
+ return errors.errorInternalError(res)
+ }
}
models.Note.create({
ownerId: owner,