我如何限制Slack应用程序以仅在添加的私有频道中检索用户信息?

发布于 2025-02-09 15:07:29 字数 218 浏览 1 评论 0原文

我有一个Slack应用程序,该应用程序正在请求权限用户:read,users.read.email。该应用程序将被添加到私人频道#xyz中。我不希望此应用程序从任何公共渠道检索信息,并仅限于扩展添加此应用程序的用户信息(此处#xyz)。 使用用户。阅读范围此应用程序可以调用用户。LISTAPI(Slack Team中的所有用户列出),并在我的工作区中获取用户的信息。

如何处理它以限制添加的专用渠道的响应?

I have a slack app which is requesting a permission users:read , users.read.email. This app will be added to a private channel say #xyz. I do not want this app to retrieve information from any public channel and be limited to extact the user info where this app is added(#xyz here).
With users.read scope this app can call users.list api (list all users in a Slack team) and get the info of users in my workspace.

How can I handle this to limit the response from the private channel where it is added?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凤舞天涯 2025-02-16 15:07:29

不幸的是,在调用users.list方法时,无法防止从公共渠道出现数据。也很难基于通道ID过滤数据,因为此方法不会返回通道数据。您需要调用对话。list并过滤所有私人频道。使用机器人令牌时,您只会看到机器人是其成员的频道的私人频道数据。检查is_private:true标志以确定频道是否是私有的。

然后,对于每个私有频道,您可以调用对话。会员方法以获取该频道中所有用户的用户ID列表。然后,您需要在返回的每个用户ID上调用users.info

这不是最优雅的方法,但我想不出一种简单的方式。

Unfortunately, there is no way to prevent data from public channels to appear when calling the users.list method. It would also be difficult to filter data based on channel id because this method does not return channel data. You would need to make a call to conversations.list and filter out all private channels. When using your bot token, you will only see private channel data for channels that your bot is a member of. Check for the is_private:true flag to determine whether a channel is private.

Then for each private channel you could then call the conversations.members method to get a list of user ids for all the users in that channel. You'd then need to call users.info on each user id that's returned.

Not the most elegant way to go about it but I can't think of an easier way I'm afraid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文