Тот же сервер, который я использую для своего приложения, также может обслуживать другие страницы. Я хотел бы использовать развертывание ссылок, чтобы добавить карточку, когда в сообщение добавляются какие-либо ссылки на эти страницы. Развертывание моей ссылки работает до тех пор, пока домен не является доменом сервера приложения. Когда это то же самое, я вижу в выводе отладки на моем сервере, что 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(`\nhandleTeamsAppBasedLinkQuery: ` + 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 во время тестирования, есть ли шанс, что он кеширует что-то? Я видел другое странное поведение, когда команды разворачивали ссылки, используя карту, которая уже была вставлена, и никогда не вызывали мою службу, я знаю, потому что служба даже не работала.
в браузере инспектор показывает следующие ошибки:
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