@@ -4,6 +4,8 @@ import { PropsForAttachment } from '../../../../../../state/ducks/conversations'
44import { Flex } from '../../../../../basic/Flex' ;
55import { tr } from '../../../../../../localization/localeTools' ;
66import { saveLogToDesktop } from '../../../../../../util/logger/renderer_process_logging' ;
7+ import { extractDetailsFromUrlFragment } from '../../../../../../session/url' ;
8+ import { isDevProd } from '../../../../../../shared/env_vars' ;
79
810type Props = {
911 attachment : PropsForAttachment ;
@@ -16,7 +18,7 @@ const StyledLabelContainer = styled(Flex)`
1618 }
1719` ;
1820
19- function formatAttachmentUrl ( attachment : PropsForAttachment ) {
21+ function formatAttachmentUrl ( attachment : Pick < PropsForAttachment , 'url' > ) {
2022 // Note: desktop overwrites the url with the local path once the file is downloaded,
2123 // and I think this is how we know the file was downloaded.
2224
@@ -38,12 +40,23 @@ function formatAttachmentUrl(attachment: PropsForAttachment) {
3840 return fileId ;
3941}
4042
43+ function extractAttachmentDetails ( attachment : Pick < PropsForAttachment , 'url' > ) {
44+ const fileUrl = URL . canParse ( attachment ?. url ) && new URL ( attachment . url ) ;
45+ return {
46+ deterministicEncryption :
47+ ( fileUrl && extractDetailsFromUrlFragment ( fileUrl ) ?. deterministicEncryption ) || false ,
48+ fsHost : fileUrl ? fileUrl . hostname : tr ( 'attachmentsNa' ) ,
49+ } ;
50+ }
51+
4152export const AttachmentInfo = ( props : Props ) => {
4253 const { attachment } = props ;
4354
4455 // NOTE the attachment.url will be an empty string if the attachment is broken
4556 const hasError = attachment . error || attachment . url === '' ;
4657
58+ const { deterministicEncryption, fsHost } = extractAttachmentDetails ( attachment ) ;
59+
4760 return (
4861 < Flex $container = { true } $flexDirection = "column" $flexGap = "var(--margins-xs)" >
4962 < LabelWithInfo label = { tr ( 'attachmentsFileId' ) } info = { formatAttachmentUrl ( attachment ) } />
@@ -79,6 +92,15 @@ export const AttachmentInfo = (props: Props) => {
7992 } }
8093 />
8194 ) : null }
95+ { isDevProd ( ) ? (
96+ < >
97+ < LabelWithInfo
98+ label = "Uses Deterministic Encryption"
99+ info = { deterministicEncryption ? 'Yes' : 'No' }
100+ />
101+ < LabelWithInfo label = "Fs host" info = { fsHost } />
102+ </ >
103+ ) : null }
82104 </ StyledLabelContainer >
83105 </ Flex >
84106 ) ;
0 commit comments