Skip to content

Commit

Permalink
Merge pull request #2762 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
Bugfixes and improvements
  • Loading branch information
JohnDuprey authored Aug 2, 2024
2 parents c7b6f31 + fde2501 commit f36880f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/views/cipp/Extensions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default function CIPPExtensions() {
setExtensionconfig({
path: 'api/ExecExtensionsConfig',
values: values,
}).then((res) => {
listBackend({ path: 'api/ListExtensionsConfig' })
})
}

Expand Down
34 changes: 25 additions & 9 deletions src/views/email-exchange/tools/MessageViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const MessageViewer = ({ emailSource }) => {
const [emlContent, setEmlContent] = useState(null)
const [emlError, setEmlError] = useState(false)
const [messageHtml, setMessageHtml] = useState('')
const [emlHeaders, setEmlHeaders] = useState(null)

const getAttachmentIcon = (contentType) => {
if (contentType.includes('image')) {
Expand Down Expand Up @@ -126,21 +127,32 @@ const MessageViewer = ({ emailSource }) => {
return d instanceof Date && !isNaN(d)
}

const showEmailModal = (emailSource) => {
const showEmailModal = (emailSource, title = 'Email Source') => {
ModalService.open({
data: emailSource,
componentType: 'codeblock',
title: 'Email Source',
title: title,
size: 'lg',
})
}

const EmailButtons = (emailSource) => {
const EmailButtons = (emailHeaders, emailSource) => {
const emailSourceBytes = new TextEncoder().encode(emailSource)
const blob = new Blob([emailSourceBytes], { type: 'message/rfc822' })
const url = URL.createObjectURL(blob)
return (
<CButton onClick={() => showEmailModal(emailSource)}>
<FontAwesomeIcon icon="file-code" className="me-2" />
View Source
</CButton>
<span>
{emailHeaders && (
<CButton onClick={() => showEmailModal(emailHeaders, 'Email Headers')} className="me-2">
<FontAwesomeIcon icon="file-code" className="me-2" />
View Headers
</CButton>
)}
<CButton onClick={() => showEmailModal(emailSource)}>
<FontAwesomeIcon icon="envelope" className="me-2" />
View Source
</CButton>
</span>
)
}

Expand All @@ -150,6 +162,7 @@ const MessageViewer = ({ emailSource }) => {
setEmlError(true)
setEmlContent(null)
setMessageHtml(null)
setEmlHeaders(null)
} else {
setEmlContent(ReadEmlJson)
setEmlError(false)
Expand All @@ -160,11 +173,14 @@ const MessageViewer = ({ emailSource }) => {
} else {
setMessageHtml(null)
}
const header_regex = /(?:^[\w-]+:\s?.*(?:\r?\n[ \t].*)*\r?\n?)+/gm
const headers = emailSource.match(header_regex)
setEmlHeaders(headers ? headers[0] : null)
}
})
}, [emailSource, setMessageHtml, setEmlError, setEmlContent])
}, [emailSource, setMessageHtml, setEmlError, setEmlContent, setEmlHeaders])

var buttons = EmailButtons(emailSource)
var buttons = EmailButtons(emlHeaders, emailSource)

return (
<>
Expand Down

0 comments on commit f36880f

Please sign in to comment.