transition to application/json+drafty as mime type for form responses
This commit is contained in:
@@ -44,6 +44,9 @@ const messages = defineMessages({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const JSON_MIME_TYPE = 'application/json+drafty';
|
||||||
|
const JSON_MIME_TYPE_LEGACY = 'application/json'; // Remove in 2026.
|
||||||
|
|
||||||
// The main Drafty formatter: converts Drafty elements into React classes. 'this' is set by the caller.
|
// The main Drafty formatter: converts Drafty elements into React classes. 'this' is set by the caller.
|
||||||
// 'this' must contain:
|
// 'this' must contain:
|
||||||
// viewportWidth:
|
// viewportWidth:
|
||||||
@@ -304,7 +307,7 @@ export function previewFormatter(style, data, values, key) {
|
|||||||
break;
|
break;
|
||||||
case 'EX':
|
case 'EX':
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.mime == 'application/json') {
|
if (data.mime == JSON_MIME_TYPE || data.mime == JSON_MIME_TYPE_LEGACY) {
|
||||||
// Ignore JSON attachments: they are form response payloads.
|
// Ignore JSON attachments: they are form response payloads.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -426,7 +429,7 @@ function quoteFormatter(style, data, values, key) {
|
|||||||
case 'EX':
|
case 'EX':
|
||||||
let fname;
|
let fname;
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.mime == 'application/json') {
|
if (data.mime == JSON_MIME_TYPE || data.mime == JSON_MIME_TYPE_LEGACY) {
|
||||||
// Ignore JSON attachments: they are form response payloads.
|
// Ignore JSON attachments: they are form response payloads.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,8 +162,9 @@ class BaseChatMessage extends React.PureComponent {
|
|||||||
const attachments = [];
|
const attachments = [];
|
||||||
if (this.props.mimeType == Drafty.getContentType() && Drafty.isValid(content)) {
|
if (this.props.mimeType == Drafty.getContentType() && Drafty.isValid(content)) {
|
||||||
Drafty.attachments(content, (att, i) => {
|
Drafty.attachments(content, (att, i) => {
|
||||||
if (att.mime == 'application/json') {
|
if (att.mime == 'application/json+drafty' ||
|
||||||
// Don't show json objects as attachments.
|
att.mime == 'application/json') {
|
||||||
|
// Don't show json drafty form response objects as attachments.
|
||||||
// They are not meant for users.
|
// They are not meant for users.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -7712,6 +7712,8 @@ const messages = (0,react_intl__WEBPACK_IMPORTED_MODULE_1__.defineMessages)({
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const JSON_MIME_TYPE = 'application/json+drafty';
|
||||||
|
const JSON_MIME_TYPE_LEGACY = 'application/json';
|
||||||
function fullFormatter(style, data, values, key, stack) {
|
function fullFormatter(style, data, values, key, stack) {
|
||||||
if (stack.includes('QQ')) {
|
if (stack.includes('QQ')) {
|
||||||
return quoteFormatter.call(this, style, data, values, key);
|
return quoteFormatter.call(this, style, data, values, key);
|
||||||
@@ -7937,7 +7939,7 @@ function previewFormatter(style, data, values, key) {
|
|||||||
break;
|
break;
|
||||||
case 'EX':
|
case 'EX':
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.mime == 'application/json') {
|
if (data.mime == JSON_MIME_TYPE || data.mime == JSON_MIME_TYPE_LEGACY) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
delete data.val;
|
delete data.val;
|
||||||
@@ -8056,7 +8058,7 @@ function quoteFormatter(style, data, values, key) {
|
|||||||
case 'EX':
|
case 'EX':
|
||||||
let fname;
|
let fname;
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.mime == 'application/json') {
|
if (data.mime == JSON_MIME_TYPE || data.mime == JSON_MIME_TYPE_LEGACY) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
fname = data.name;
|
fname = data.name;
|
||||||
@@ -16514,7 +16516,7 @@ class BaseChatMessage extends (react__WEBPACK_IMPORTED_MODULE_0___default().Pure
|
|||||||
const attachments = [];
|
const attachments = [];
|
||||||
if (this.props.mimeType == tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.getContentType() && tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.isValid(content)) {
|
if (this.props.mimeType == tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.getContentType() && tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.isValid(content)) {
|
||||||
tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.attachments(content, (att, i) => {
|
tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.attachments(content, (att, i) => {
|
||||||
if (att.mime == 'application/json') {
|
if (att.mime == 'application/json+drafty' || att.mime == 'application/json') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
attachments.push(react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_attachment_jsx__WEBPACK_IMPORTED_MODULE_3__["default"], {
|
attachments.push(react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_attachment_jsx__WEBPACK_IMPORTED_MODULE_3__["default"], {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user