transition to application/json+drafty as mime type for form responses

This commit is contained in:
or-else
2025-08-07 15:39:43 +03:00
parent 7ce9470bf3
commit 290571f305
6 changed files with 16 additions and 10 deletions
+5 -2
View File
@@ -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.
// 'this' must contain:
// viewportWidth:
@@ -304,7 +307,7 @@ export function previewFormatter(style, data, values, key) {
break;
case 'EX':
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.
return null;
}
@@ -426,7 +429,7 @@ function quoteFormatter(style, data, values, key) {
case 'EX':
let fname;
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.
return null;
}
+3 -2
View File
@@ -162,8 +162,9 @@ class BaseChatMessage extends React.PureComponent {
const attachments = [];
if (this.props.mimeType == Drafty.getContentType() && Drafty.isValid(content)) {
Drafty.attachments(content, (att, i) => {
if (att.mime == 'application/json') {
// Don't show json objects as attachments.
if (att.mime == 'application/json+drafty' ||
att.mime == 'application/json') {
// Don't show json drafty form response objects as attachments.
// They are not meant for users.
return;
}