0

我尝试了不同的方法但没有运气

var user = Session.getUser();
var userEmail = user.getEmail();
var viewers = someFolder.getViewers()
return (user in viewers)

还有这个

return (userEmail in viewers)
return (viewers.indexOf(userEmail) != -1)

这可能微不足道,但对我来说不是

谢谢,福斯托

4

1 回答 1

1

Folder.getViewers方法返回用户列表,您的代码搜索电子邮件,该电子邮件是作为对象的用户列表中的字符串。一个解决方案是

function testUser() {
  var bUserFound = false;
  var user = Session.getUser();
  var userEmail = user.getEmail();
  var viewers = someFolder.getViewers();
  for (var i = 0; i < viewers.length; i++) {
    var viewer = viewers[i];
    if (viewer.getEmail() == userEmail) {
      bUserFound = true;
      break;
    }
  }
  return bUserFound;
}
于 2012-10-04T04:34:57.983 回答