wechaty / wechaty-puppet-padpro

Apache License 2.0
238 stars 63 forks source link

A friend that appears in the buddy list, does not exist. #143

Open qiqizjl opened 5 years ago

qiqizjl commented 5 years ago

重要:请不要删除模板自行填写,所有不按照模板填写的issue,我们将不会处理。

0. 发 Issue 指南

  1. 请运行下面的命令,看问题是否可以被解决:

    rm -rf package-lock.json
    rm -rf node_modules
    npm install
  2. 请在 FAQ 清单 看是否已有解决办法。

  3. 请先在issue 中搜关键信息,确认你要发的内容和之前的issue 不重复。

1. 提供你的包版本信息

2. Bug 描述

Use the Contact.findAll() interface to get the buddy list. After filtering friend() and type, I found that some users are not my friends. But the display is my friend. I set him an alias. It will also give an error.

3. 复现的步骤 (或者解决的步骤)

这一部分非常重要,如果你无法给出复现步骤,我们也很难提供相应的解决办法:

复现步骤中一定要给出复现代码 Use the Contact.findAll() interface to get the buddy list. After filtering friend() and type, I found that some users are not my friends. But the display is my friend. I set him an alias. It will also give an error.

    const user = await ctx.service.response.fmtUserList(await app.wechat.Contact.findAll());

  public async fmtUserList(userList: Contact[]): Promise<User[]> {
    const res = [] as User[];
    await userList.forEach(async data => {
      // 过滤非好友
      if (!data.friend()) {
        return;
      }
      // 过滤公众号
      if (data.type() !== ContactType.Personal) {
        return;
      }
      // 过滤系统级用户 暂时维护白名单List
      if (this.systemUser.indexOf(data.id) !== -1) {
        return;
      }
      res.push({
        name: data.name(),
        star: data.star() || false,
        alias: await data.alias() || '',
        id: data.id,
        wechat_id: data.weixin(),
        user_id: await this.service.user.getUserID(data),
      } as User);
    });
    return res;
  }

 public async getUserID(user: Contact): Promise<string> {
    let alias = await user.alias();
    if (alias == null) {
      alias = uuid.v4();
      await user.alias(alias);
    }
    return alias;
  }

4. 期待程序运行的结果

Do not return this user

5. 程序实际运行的结果

Return the user and set alias failed image

6. 完整的日志信息:

通过WECHATY_LOG=silly设定环境变量,将设置log 等级为 silly,获取最详细的日志信息(默认log 等级为 info) 请提供完整的日志信息(不要只提供部分的日志截图,请复制粘贴日志内容!) The log is a bit big, please download the zip file. padpro.log.zip

7. 其他信息

有相关bug 的背景信息,可以在这里说明

[bug]

xinbenlv commented 5 years ago

我有同样的问题