如何通过身份删除会话参与者用户

How to delete a conversation participant user by its identity

我通过 API REST 将用户添加到对话中。例如我这样做:

await client.conversations
    .services(TWILIO_CHAT_SERVICE_SID)
    .conversations(conversationSid)
    .participants.create({ identity: myIdentity });

考虑到我只需要通过 API REST 从对话中删除用户。我发现 here 如何通过其 sid 删除它们。有没有办法通过其身份删除它们?我需要这样做,因为我不会将参与者的 sid 跟踪到我的数据库中。如果必须的话我会的。

那么你会如何面对这个问题呢?

我认为您需要 SID。值得庆幸的是,当您在对话中创建参与者时,API 会使用 SID 进行响应。

const participant = await client.conversations
    .services(TWILIO_CHAT_SERVICE_SID)
    .conversations(conversationSid)
    .participants.create({ identity: myIdentity });

console.log(participant.sid);

因此,当您创建参与者时,存储他们的 SID。然后当你需要更新或删除它们时,你可以从你自己的数据库中获取它们的 SID。