google-apps-script - 是否可以在 Google Apps 脚本中创建 getCommenters() 功能?
问题描述
Google Apps Script的DriveApp > File 类提供以下方法:
但getCommenters
方法不可用。(这很有趣,因为addCommenter
、addCommenters
和removeCommenter
方法可用。)
我正在制作一个脚本,我正在根据电子表格中的电子邮件地址更改文件和文件夹权限。我想要一个getCommenters
功能,以便我可以比较电子表格中的评论者电子邮件是否已经是文件的评论者,因此无需再次使用addCommenters
. (按下它会为用户生成一封新电子邮件。)使用查看器和编辑器执行此操作没有问题,因为方法是可用的。
问题:是否有可能创建一个模仿假设功能的函数getCommenters
?或者至少提取评论者的一系列电子邮件地址?
解决方案
getViewers()
返回观众和评论员。您可以使用以下方式过滤列表getAccess()
:
const getCommenters = (file) =>
file.getViewers().filter(user=>
file.getAccess(user) == "COMMENT")
推荐阅读
- python - 尝试在 Tensorflow 中初始化神经网络,收到 TypeError
- c# - 设置 SystemMediaTransportControlsDisplayUpdater 的缩略图
- java - 使用for循环在数组中查找最大值和最小值?
- c# - Sentry - 向用户上下文添加任意键/值对
- arrays - 为什么连接这两个字符串会在 Go 中将最后 3 个字符移到组合字符串的前 3 个字符上?
- python - 如何在 loc 中使用具有多种可能格式的变量来切片带有 DatetimeIndex 的 pandas 数据帧
- php - Laravel:同一张表,一对一的关系
- ssl - 如何取消阻止自签名 SSL 证书?
- javascript - 请解释 IIFE 的两种语法
- javascript - v-for 之后的标签中出现意外的字符串