Quellcode durchsuchen

add chat membership posting check

asmer@controller vor 3 Jahren
Ursprung
Commit
25f68a9a2a
1 geänderte Dateien mit 4 neuen und 0 gelöschten Zeilen
  1. 4 0
      models.js

+ 4 - 0
models.js

@@ -123,7 +123,11 @@ module.exports = async (dbName='graphql-chat') => {
                 if (!this.chat){
                 if (!this.chat){
                     throw new ReferenceError("You should set chat")
                     throw new ReferenceError("You should set chat")
                 }
                 }
+
                 const chatId = this.chat._id.toString()
                 const chatId = this.chat._id.toString()
+                if (!chatACL.includes(chatId)) {
+                    throw new ReferenceError("You cannot post to chat without membership.")
+                }
 
 
                 this.___permissions.read.push(chatId)
                 this.___permissions.read.push(chatId)
                 this.___permissions.read = [...new Set(this.___permissions.read)]
                 this.___permissions.read = [...new Set(this.___permissions.read)]