简体   繁体   English

Microsoft团队:如何设置聊天消息的作者?

[英]Microsoft Teams: How to set the author of a chat message?

The Teams Beta Chat API allows posting messages to a channel. Teams Beta Chat API允许将消息发布到频道。 Good. 好。 I want to specify the author of this message (which shall not be me, but an arbitraryly chosen user). 我想指定此消息的作者(不是我,而是一个任意选择的用户)。 Can this be done? 能做到吗? How? 怎么样?

More context 更多背景

We need to set the author in a migration scenario where messages from another system must be migrated to Teams. 我们需要在需要将来自另一个系统的消息迁移到团队的迁移场景中设置作者。

The documentation of the chatMessage resource type (used by the /chatmessage endpoint) lists some properties as read-only, but the from field is none of them. chatMessage资源类型的文档 (由/chatmessage端点使用)将某些属性列出为只读,但是from字段中没有。 This leaves the impression that the author can be set. 这给人留下了可以设置作者的印象。

This is the POST body I tried: 这是我尝试过的POST正文:

{
  "body": {
    "contentType": "html",
    "content": "Hello World",
    "from": {
      "user": {
        "displayName": "Heinrich Ulbricht"
      }
    }
  }
}

This gives me a 500 response from the server. 这给了我来自服务器的500响应。 I also tried setting the id of the user. 我也尝试设置用户的ID。 Same result: error 500. 结果相同:错误500。

Removing the from property succeeds and posts the message. 成功删除from属性并发布消息。 This is the endpoint I used: https://graph.microsoft.com/beta/teams/<id>/channels/<id>/messages 这是我使用的端点: https://graph.microsoft.com/beta/teams/<id>/channels/<id>/messages : https://graph.microsoft.com/beta/teams/<id>/channels/<id>/messages

So is it possible to set the author of a chat message? 那么可以设置聊天消息的作者吗?

It is not yet possible to impersonate another user in any API, Graph or Bot. 尚无法在任何API,Graph或Bot中模拟其他用户。 We are planning to do this at some point but it will require elevated privilege and the ability to annotate the message as having been created by an API as opposed to a user and making it possible to audit for these types of annotations later. 我们计划在某个时候进行此操作,但是这需要更高的特权,并且需要具有对消息进行注释的功能,该消息是由API(而不是用户)创建的,并且以后可以审核这些类型的注释。 Otherwise it's a huge security hole. 否则,这是一个巨大的安全漏洞。

Building these underlying capabilities is why we don't support migration scenarios. 建立这些基础功能是我们不支持迁移方案的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM