当目标域与应用程序的Web服务相同时是否可以展开链接?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了当目标域与应用程序的Web服务相同时是否可以展开链接?相关的知识,希望对你有一定的参考价值。

我在我的应用中使用的同一服务器也可以提供其他页面。当到这些页面的任何链接添加到邮件时,我想使用链接展开来添加卡片。只要该域不是应用程序的服务器域,其他链接就可以工作。当相同时,我可以在服务器的调试输出中看到MS Teams试图打开链接。

经过更多测试后,我发现我的处理程序确实被呼叫了,但未插入卡。如果我开始发送新消息并再次粘贴URL,即使未致电我的服务,该卡也不会出现。

我的清单看起来像这样:

{
  "$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
  "manifestVersion": "1.5",
  "version": "1.25",
  "id": "xxxxxxx-xxxxxxx-xxxxxxx-xxxxxxx-xxxxxxx",
  "packageName": "xxxxxxx",
  "developer": {
    "name": "xx",
    "websiteUrl": "https://www.xx.com",
    "privacyUrl": "https://xxxx.com/en/privacy-policy/",
    "termsOfUseUrl": "https://xxxx.com/en/terms-and-conditions/"
  },
  "name": {
    "short": "xxxxxxx",
    "full": "xxxxxxx"
  },
  "description": {
    "short": "xxxxxxx",
    "full": "xxxxxxx"
  },
  "icons": {
    "outline": "xxxxxxx-outline.png", 
    "color": "xxxxxxx-color.png"
  },
  "accentColor": "#FFFFFF",
  "composeExtensions": [
    {
      "botId": "xxxxxxx-xxxxxxx-xxxxxxx-xxxxxxx-xxxxxxx",
      "canUpdateConfiguration": false,
      "commands": [
      ],
      "messageHandlers": [
      {
        "type": "link",
        "value": {
          "domains": [
          "*.xxxxxxx.net",
          "*.ngrok.io"
          ]
        }
      }
    ]
    }
  ],
   "validDomains": [
   "*.xxxxxxx.net",
     "*.ngrok.io"

  ]
}

这是我的处理程序:

const { TeamsActivityHandler, CardFactory } = require('botbuilder');


class TeamsMessagingExtensionsActionBot extends TeamsActivityHandler {


     handleTeamsAppBasedLinkQuery(context, query) { 
                console.log(`
handleTeamsAppBasedLinkQuery: `  + query.url);
        var parts = query.url.split("/");
        var sizeStr = parts[6].replace("-", " ");;
        var dir = parts[7];     
        var file = parts[8];

        var card = {
            contentType: 'application/vnd.microsoft.card.hero',
            content: { 
                title: 'File: ' + file,
                subtitle:'Dir: ' + dir,
                text: 'Size: '+ sizeStr
            }
        };

        console.log(card);
        const result = {
          attachmentLayout: 'list',
          type: 'result',
          attachments: [card]
        };

        const response = {
          composeExtension: result
        };
        return response;
      }
 }
module.exports.TeamsMessagingExtensionsActionBot = TeamsMessagingExtensionsActionBot;

我在测试时使用ngok,是否有可能将其缓存?我看到了其他一些奇怪的行为,其中Teams正在使用已经插入的卡来展开链接,并且从未调用过我的服务,我知道是因为该服务甚至没有在运行。

[我发现如果我在浏览器中运行团队,检查器将显示以下错误:

Content Security Policy: Ignoring "'unsafe-inline'" within script-src or style-src: nonce-source or hash-source specified
GEThttps://eu-api.asm.skype.com/v1/objects/0-neu-d9-f79c02c35893b017803e3a0781c147c0/views/imgpsh_fullsize
[HTTP/1.1 200 OK 0ms]

Content Security Policy: Ignoring "'unsafe-inline'" within script-src or style-src: nonce-source or hash-source specified 2
Content Security Policy: Ignoring "'unsafe-inline'" within script-src or style-src: nonce-source or hash-source specified
[Bot invoke failed]: <BotError>Bot returned unsuccessful status code NotFound 3.2-app.min-0f0e437.js:4:1729883
    postInvokeMessageWithUserInfo https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:4
    jQuery 4
        f
        g
        $eval
        $digest
    $digest https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:4
    jQuery 4
        $apply
        m
        x
        onload
{…}
​
errorCode: 1008
​
errorMessage: "<BotError>Bot returned unsuccessful status code NotFound"
​
errorSubCode: undefined
​
headers: {…}
​​
"cache-control": "no-store, must-revalidate, no-cache"
​​
"content-length": "87"
​​
"content-type": "application/json; charset=utf-8"
​​
contextid: "tcid=965107910583198700,server=DB3PEPF000012A0,cv=ViFTxnq4MUSzogp8N8o9zg.1.0"
​​
pragma: "no-cache"
​​
"set-registrationtoken": "**redacted**"
​
request: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
​
statusCode: 502
​
<prototype>: Object { … }
 undefined 0-angular-jquery.min-eee9041.js:114:37
2020-06-16T21:13:53.449Z InputExtensionService: Input extension invoke command failed 0-angular-jquery.min-eee9041.js:114:37
    e jQuery
    logMessage https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:4
    error https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:4
    runCommand https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:3
    jQuery 4
        f
        g
        $eval
        $digest
    $digest https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:4
    jQuery 4
        $apply
        m
        x
        onload
2020-06-16T21:14:43.904Z StorageUsage: Error ocrrured collecting storage usage numbers for the user. Error:navigator.webkitTemporaryStorage.queryUsageAndQuota 0-angular-jquery.min-eee9041.js:114:37
    e jQuery
    logMessage https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:4
    error https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:4
    startStorageUsageCollector https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:4
    _resolveFailures https://statics.teams.cdn.office.net/hashedjs/3.1-app.min-84b23e5.js:942
    r https://statics.teams.cdn.office.net/hashedjs/3.1-app.min-84b23e5.js:942
    _resolveFailures https://statics.teams.cdn.office.net/hashedjs/3.1-app.min-84b23e5.js:942
    _resolveFailures https://statics.teams.cdn.office.net/hashedjs/3.1-app.min-84b23e5.js:942
    _addCallbackSet https://statics.teams.cdn.office.net/hashedjs/3.1-app.min-84b23e5.js:942
    then https://statics.teams.cdn.office.net/hashedjs/3.1-app.min-84b23e5.js:942
    startStorageUsageCollector https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-0f0e437.js:4
    jQuery 3
        n
        e
        c
答案

所有这些的原因是我的免费订阅已悄然到期,我没有注意到它。 :(

以上是关于当目标域与应用程序的Web服务相同时是否可以展开链接?的主要内容,如果未能解决你的问题,请参考以下文章

函数作用域与执行上下文

当AD域与DNS不再一台服务器上时配置

在 vps 上将域与 localhost 连接

js-高级(原型与原型链作用域与作用域链闭包)

快慢指针判断链表是否有环

(Swift)当多个视图控制器导致相同的视图时展开 segue?