浏览代码

add chat membership posting check

asmer@controller 3 年之前
父节点
当前提交
25f68a9a2a
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      models.js

+ 4 - 0
models.js

@@ -123,7 +123,11 @@ module.exports = async (dbName='graphql-chat') => {
                 if (!this.chat){
                     throw new ReferenceError("You should set chat")
                 }
+
                 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 = [...new Set(this.___permissions.read)]