diff --git a/webapp/channels/src/actions/notification_actions.tsx b/webapp/channels/src/actions/notification_actions.tsx index 59b9daacce..9dd7d1a78a 100644 --- a/webapp/channels/src/actions/notification_actions.tsx +++ b/webapp/channels/src/actions/notification_actions.tsx @@ -331,7 +331,9 @@ function shouldSkipNotification( if (attachment.fields) { for (const field of attachment.fields) { appendText(field.title); - appendText(field.value); + if (typeof field.value === 'string') { + appendText(field.value); + } } } } diff --git a/webapp/channels/src/components/post_view/message_attachments/action_button/action_button.tsx b/webapp/channels/src/components/post_view/message_attachments/action_button/action_button.tsx index 48db65c43a..071065568b 100644 --- a/webapp/channels/src/components/post_view/message_attachments/action_button/action_button.tsx +++ b/webapp/channels/src/components/post_view/message_attachments/action_button/action_button.tsx @@ -56,6 +56,8 @@ const ActionButton = ({ (action.style.match('^#(?:[0-9a-fA-F]{3}){1,2}$') && action.style); } + const name = action.name || action.id || ''; + return ( diff --git a/webapp/channels/src/components/post_view/message_attachments/action_menu/action_menu.tsx b/webapp/channels/src/components/post_view/message_attachments/action_menu/action_menu.tsx index e78a8cf630..258f25fa75 100644 --- a/webapp/channels/src/components/post_view/message_attachments/action_menu/action_menu.tsx +++ b/webapp/channels/src/components/post_view/message_attachments/action_menu/action_menu.tsx @@ -99,6 +99,7 @@ export default class ActionMenu extends React.PureComponent { render() { const {action, disabled} = this.props; + const name = action.name || action.id || ''; return ( @@ -106,7 +107,7 @@ export default class ActionMenu extends React.PureComponent { const content = [] as JSX.Element[]; - actions.forEach((action: PostAction) => { + actions.forEach((action) => { if (!action.id || !action.name) { return; } diff --git a/webapp/platform/types/src/integration_actions.ts b/webapp/platform/types/src/integration_actions.ts index 93064b5c5b..5b246b7afe 100644 --- a/webapp/platform/types/src/integration_actions.ts +++ b/webapp/platform/types/src/integration_actions.ts @@ -4,9 +4,9 @@ import {isArrayOf} from './utilities'; export type PostAction = { - id: string; + id?: string; type?: string; - name: string; + name?: string; disabled?: boolean; style?: string; data_source?: string; @@ -20,19 +20,11 @@ export function isPostAction(v: unknown): v is PostAction { return false; } - if (!('id' in v)) { + if ('id' in v && typeof v.id !== 'string') { return false; } - if (typeof v.id !== 'string') { - return false; - } - - if (!('name' in v)) { - return false; - } - - if (typeof v.name !== 'string') { + if ('name' in v && typeof v.name !== 'string') { return false; } diff --git a/webapp/platform/types/src/message_attachments.ts b/webapp/platform/types/src/message_attachments.ts index 880d9a7621..13740eacfa 100644 --- a/webapp/platform/types/src/message_attachments.ts +++ b/webapp/platform/types/src/message_attachments.ts @@ -103,8 +103,8 @@ function isMessageAttachment(v: unknown): v is MessageAttachment { } export type MessageAttachmentField = { - title: string; - value: any; + title?: string; + value?: unknown; short?: boolean; }