Explorar o código

support deletion for attachment which has no creator

Yuki Takei %!s(int64=5) %!d(string=hai) anos
pai
achega
5915ecac90
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      src/server/routes/attachment.js

+ 5 - 0
src/server/routes/attachment.js

@@ -154,6 +154,11 @@ module.exports = function(crowi, app) {
    * @param {Attachment} attachment
    * @param {Attachment} attachment
    */
    */
   async function isDeletableByUser(user, attachment) {
   async function isDeletableByUser(user, attachment) {
+    // deletable if creator is null
+    if (attachment.creator == null) {
+      return true;
+    }
+
     const ownerId = attachment.creator._id || attachment.creator;
     const ownerId = attachment.creator._id || attachment.creator;
     if (attachment.page == null) { // when profile image
     if (attachment.page == null) { // when profile image
       return user.id === ownerId.toString();
       return user.id === ownerId.toString();