松弛选择中的外部数据加载

问题描述 投票:0回答:0

我正在开发一个 slack 应用程序,我在其中使用交互式块中的 slack external_select

 attachments: [
      {
        fallback: "Upgrade your Slack client to use messages like these.",
        color: "3AA3E3",
        attachment_type: "default",
        callback_id: callback_id,
        actions: [
          {
            name: "select_list",
            text: placeholder,
            type: "select",
            data_source: "external",
            min_query_length: 0,
          },
        ],
      },
    ],

当用户加载到块上方时,我也在我的控制器上收到请求。 到目前为止一切都很好,但我的问题是我无法在 3 秒内返回选项数据。

我可以增加这个时间吗?或者有什么解决方法可以在收到请求时先调用 ack() 函数,然后返回选项数组?

下面是我的控制器代码。

const selectProject = async ({ ack, body }) => {
  try {
    const { id: uid } = body?.user || {};
    const { id: workspace_id } = body?.team || {};
    const { value: keyword } = body
    const user = await getUserBySlackAndWorkspaceId(uid, workspace_id);
    const { projects } = await getUserProjects({ user, shouldPopulate: false, keyword, page: 1, pageSize: 1, order: 'desc' });

    await ack({
      options: projects,
    }); //I want to call this at the begin of controller and then return the response
  } catch (err) {
    console.log(err);
  }
};
node.js slack slack-api
© www.soinside.com 2019 - 2024. All rights reserved.