node-webot / co-wechat

Wechat for Koa
427 stars 91 forks source link

TypeError: Cannot read property 'hasOwnProperty' of null #8

Closed Cap32 closed 7 years ago

Cap32 commented 8 years ago

reply 方法下,content 可能为 null,而且 typeof null === 'object',这段代码(144行)可能会出错

if (Array.isArray(content)) {
    type = 'news';
  } else if (typeof content === 'object') { // content 可能为 null
    if (content.hasOwnProperty('type')) { // 如果 content 为 null,会报错
      if (content.type === 'customerService') {
        return reply2CustomerService(fromUsername, toUsername, content.kfAccount);
      }
      type = content.type;
      info.content = content.content;
    } else {
      type = 'music';
    }
  }
JacksonTian commented 8 years ago

Pull Request welcome.