2023-06-30 14:26:46 +00:00
|
|
|
import { LOCAL_DOCUMENT_DIRECTORY } from '../handleMediaDownload';
|
2023-05-15 18:10:43 +00:00
|
|
|
|
2022-04-07 13:13:19 +00:00
|
|
|
export const formatAttachmentUrl = (attachmentUrl: string | undefined, userId: string, token: string, server: string): string => {
|
2023-06-30 14:26:46 +00:00
|
|
|
if (LOCAL_DOCUMENT_DIRECTORY && attachmentUrl?.startsWith(LOCAL_DOCUMENT_DIRECTORY)) {
|
2023-05-15 18:10:43 +00:00
|
|
|
return attachmentUrl;
|
|
|
|
}
|
2022-04-07 13:13:19 +00:00
|
|
|
if (attachmentUrl && attachmentUrl.startsWith('http')) {
|
|
|
|
if (attachmentUrl.includes('rc_token')) {
|
|
|
|
return encodeURI(attachmentUrl);
|
|
|
|
}
|
|
|
|
return encodeURI(`${attachmentUrl}?rc_uid=${userId}&rc_token=${token}`);
|
|
|
|
}
|
|
|
|
return encodeURI(`${server}${attachmentUrl}?rc_uid=${userId}&rc_token=${token}`);
|
|
|
|
};
|