mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-28 18:59:44 +02:00
Merge pull request
This commit is contained in:
@@ -1,44 +1,28 @@
|
||||
import { useLocal } from '../../Utils.js';
|
||||
import getPresignedUrl, { presignedlocalUrl } from './getSignedUrl.js';
|
||||
|
||||
const resolveUrl = async rawUrl => {
|
||||
const isLocal = useLocal == 'true';
|
||||
const shouldUsePresigned = useLocal !== 'true';
|
||||
if (!rawUrl) return rawUrl;
|
||||
if (shouldUsePresigned) {
|
||||
return await getPresignedUrl(rawUrl);
|
||||
} else if (isLocal) {
|
||||
return presignedlocalUrl(rawUrl);
|
||||
}
|
||||
};
|
||||
|
||||
async function SignatureAfterFind(request) {
|
||||
if (useLocal !== 'true') {
|
||||
if (request.objects.length === 1) {
|
||||
if (request.objects) {
|
||||
const obj = request.objects[0];
|
||||
const ImageURL = obj?.get('ImageURL') && obj?.get('ImageURL');
|
||||
const Initials = obj?.get('Initials') && obj?.get('Initials');
|
||||
const Stamp = obj?.get('Stamp') && obj?.get('Stamp');
|
||||
if (ImageURL) {
|
||||
obj.set('ImageURL', getPresignedUrl(ImageURL));
|
||||
}
|
||||
if (Initials) {
|
||||
obj.set('Initials', getPresignedUrl(Initials));
|
||||
}
|
||||
if (Stamp) {
|
||||
obj.set('Stamp', getPresignedUrl(Stamp));
|
||||
}
|
||||
return [obj];
|
||||
}
|
||||
}
|
||||
} else if (useLocal == 'true') {
|
||||
if (request.objects.length === 1) {
|
||||
if (request.objects) {
|
||||
const obj = request.objects[0];
|
||||
const ImageURL = obj?.get('ImageURL') && obj?.get('ImageURL');
|
||||
const Initials = obj?.get('Initials') && obj?.get('Initials');
|
||||
const Stamp = obj?.get('Stamp') && obj?.get('Stamp');
|
||||
if (ImageURL) {
|
||||
obj.set('ImageURL', presignedlocalUrl(ImageURL));
|
||||
}
|
||||
if (Initials) {
|
||||
obj.set('Initials', presignedlocalUrl(Initials));
|
||||
}
|
||||
if (Stamp) {
|
||||
obj.set('Stamp', presignedlocalUrl(Stamp));
|
||||
}
|
||||
return [obj];
|
||||
}
|
||||
if (request.objects.length === 1) {
|
||||
if (request.objects) {
|
||||
const obj = request.objects[0];
|
||||
const ImageURL = obj?.get('ImageURL') && obj?.get('ImageURL');
|
||||
const Initials = obj?.get('Initials') && obj?.get('Initials');
|
||||
const Stamp = obj?.get('Stamp') && obj?.get('Stamp');
|
||||
if (ImageURL) obj.set('ImageURL', await resolveUrl(ImageURL));
|
||||
if (Initials) obj.set('Initials', await resolveUrl(Initials));
|
||||
if (Stamp) obj.set('Stamp', await resolveUrl(Stamp));
|
||||
return [obj];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user