2026-10-06 22:12:49 +00:00
|
|
|
// Module ID: 5442
|
|
|
|
|
// Function ID: 5443
|
2026-09-18 20:18:48 +00:00
|
|
|
// Name: UploadUtils
|
2026-10-06 22:12:49 +00:00
|
|
|
// Dependencies: [5443, 5444, 5441, 2]
|
2026-09-18 20:18:48 +00:00
|
|
|
// Exports: getAttachmentPayload, getFile, getFileContentLength, getFileData, getMaxTotalAttachmentSize
|
|
|
|
|
|
2026-10-06 22:12:49 +00:00
|
|
|
// Module 5442 (UploadUtils)
|
|
|
|
|
import Upload from "Upload" /* 5441 */;
|
|
|
|
|
import NitroFileUploadExperiments from "NitroFileUploadExperiments" /* 5443 */;
|
|
|
|
|
import clipPayloadUtils from "clipPayloadUtils" /* 5444 */;
|
2026-09-18 20:18:48 +00:00
|
|
|
import size from "module_2" /* 2 */;
|
|
|
|
|
|
2026-10-06 22:12:49 +00:00
|
|
|
let reName;
|
|
|
|
|
|
|
|
|
|
let obj = {
|
|
|
|
|
reName: /\.jpe?g$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "image" + arg0 + ".jpg";
|
2026-09-18 20:18:48 +00:00
|
|
|
},
|
2026-10-06 22:12:49 +00:00
|
|
|
type: "image/jpeg"
|
|
|
|
|
};
|
|
|
|
|
const items = [
|
|
|
|
|
obj,
|
2026-09-18 20:18:48 +00:00
|
|
|
{
|
|
|
|
|
reName: /\.jfif$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "image" + arg0 + ".jpg";
|
|
|
|
|
},
|
|
|
|
|
type: "image/jpeg"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.png$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "image" + arg0 + ".png";
|
|
|
|
|
},
|
|
|
|
|
type: "image/png"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.gif$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "image" + arg0 + ".gif";
|
|
|
|
|
},
|
|
|
|
|
type: "image/gif"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.webp$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "image" + arg0 + ".webp";
|
|
|
|
|
},
|
|
|
|
|
type: "image/webp"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.avif$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "image" + arg0 + ".avif";
|
|
|
|
|
},
|
|
|
|
|
type: "image/avif"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.heic$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "image" + arg0 + ".heic";
|
|
|
|
|
},
|
|
|
|
|
type: "image/heic"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.heif$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "image" + arg0 + ".heif";
|
|
|
|
|
},
|
|
|
|
|
type: "image/heif"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.dng$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "image" + arg0 + ".dng";
|
|
|
|
|
},
|
|
|
|
|
type: "image/x-adobe-dng"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.mov$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "video" + arg0 + ".mov";
|
|
|
|
|
},
|
|
|
|
|
type: "video/quicktime"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.qt$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "video" + arg0 + ".qt";
|
|
|
|
|
},
|
|
|
|
|
type: "video/quicktime"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.avi$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "video" + arg0 + ".avi";
|
|
|
|
|
},
|
|
|
|
|
type: "video/x-msvideo"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.mp4$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "video" + arg0 + ".mp4";
|
|
|
|
|
},
|
|
|
|
|
type: "video/mp4"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reName: /\.webm$/i,
|
|
|
|
|
name(arg0) {
|
|
|
|
|
return "video" + arg0 + ".webm";
|
|
|
|
|
},
|
|
|
|
|
type: "image/webm"
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
let c3 = 524288000;
|
|
|
|
|
let c4 = 1073741824;
|
|
|
|
|
const result = size.fileFinishedImporting("utils/UploadUtils.tsx");
|
|
|
|
|
|
|
|
|
|
export const MAX_TOTAL_ATTACHMENT_SIZE = 524288000;
|
|
|
|
|
export const MAX_TOTAL_ATTACHMENT_SIZE_1GB = 1073741824;
|
|
|
|
|
export const MAX_TOTAL_ATTACHMENT_SIZE_MB = 500;
|
|
|
|
|
export const getMaxTotalAttachmentSize = function getMaxTotalAttachmentSize(location) {
|
2026-10-06 22:12:49 +00:00
|
|
|
const _location = location.location;
|
|
|
|
|
const obj = NitroFileUploadExperiments;
|
|
|
|
|
return obj.getNitroFileUploadRolloutConfig({ location: _location }).enabled ? c4 : c3;
|
2026-09-18 20:18:48 +00:00
|
|
|
};
|
|
|
|
|
export const getAttachmentPayload = function getAttachmentPayload(id, index, name) {
|
2026-10-06 22:12:49 +00:00
|
|
|
let filename;
|
2026-09-18 20:18:48 +00:00
|
|
|
let tmp = index;
|
|
|
|
|
if (index === undefined) {
|
|
|
|
|
tmp = null;
|
|
|
|
|
}
|
|
|
|
|
let str1;
|
|
|
|
|
if (tmp != null) {
|
|
|
|
|
str1 = tmp.toString();
|
|
|
|
|
}
|
|
|
|
|
if (str1 == null) {
|
|
|
|
|
str1 = id.id;
|
|
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
const obj = { id: str1, filename, uploaded_filename: id.uploadedFilename };
|
2026-09-18 20:18:48 +00:00
|
|
|
if (null != id.description) {
|
|
|
|
|
obj.description = id.description;
|
|
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
filename = name;
|
2026-09-18 20:18:48 +00:00
|
|
|
if (name == null) {
|
|
|
|
|
filename = id.filename;
|
|
|
|
|
}
|
|
|
|
|
if (id.spoiler) {
|
|
|
|
|
obj.is_spoiler = true;
|
|
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
const tmp3 = "durationSecs" in id && null != id.durationSecs;
|
2026-09-18 20:18:48 +00:00
|
|
|
if (tmp3) {
|
|
|
|
|
obj.duration_secs = id.durationSecs;
|
|
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
const tmp4 = "waveform" in id && null != id.waveform;
|
2026-09-18 20:18:48 +00:00
|
|
|
if (tmp4) {
|
|
|
|
|
obj.waveform = id.waveform;
|
|
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
const tmp5 = "isThumbnail" in id && true === id.isThumbnail;
|
2026-09-18 20:18:48 +00:00
|
|
|
if (tmp5) {
|
|
|
|
|
obj.is_thumbnail = id.isThumbnail;
|
|
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
const tmp6 = "clip" in id && null != id.clip;
|
2026-09-18 20:18:48 +00:00
|
|
|
if (tmp6) {
|
|
|
|
|
obj.is_clip = true;
|
|
|
|
|
obj.title = id.clip.name;
|
|
|
|
|
obj.application_id = id.clip.applicationId;
|
2026-10-06 22:12:49 +00:00
|
|
|
const obj2 = clipPayloadUtils;
|
|
|
|
|
obj.clip_created_at = obj2.getClipCreatedAt(id.clip.createdAt);
|
|
|
|
|
const obj3 = clipPayloadUtils;
|
|
|
|
|
obj.clip_participant_ids = obj3.getClipParticipantIds(id.clip.users);
|
2026-09-18 20:18:48 +00:00
|
|
|
obj.clip_remote_id = id.clip.remoteClipId;
|
2026-10-06 22:12:49 +00:00
|
|
|
const obj4 = clipPayloadUtils;
|
|
|
|
|
obj.clip_events_timeline = obj4.getClipEventsTimeline(id.clip);
|
|
|
|
|
const obj5 = clipPayloadUtils;
|
|
|
|
|
obj.clip_sync_timestamp = obj5.getClipSyncTimestamp(id.clip);
|
2026-09-18 20:18:48 +00:00
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
const tmp9 = "item" in id && null != id.item && id.item.platform === Upload.UploadPlatform.WEB && "mimeType" in id && null != id.mimeType;
|
2026-09-18 20:18:48 +00:00
|
|
|
if (tmp9) {
|
|
|
|
|
obj.original_content_type = id.mimeType;
|
|
|
|
|
}
|
|
|
|
|
return obj;
|
|
|
|
|
};
|
|
|
|
|
export const getFileData = function getFileData(arg0) {
|
2026-10-06 22:12:49 +00:00
|
|
|
let closure_0 = arg0;
|
2026-09-18 20:18:48 +00:00
|
|
|
let xMLHttpRequest = new XMLHttpRequest();
|
2026-10-06 22:12:49 +00:00
|
|
|
const promise = new Promise((arg0, arg1) => {
|
|
|
|
|
let closure_1;
|
2026-09-18 20:18:48 +00:00
|
|
|
closure_0 = arg0;
|
|
|
|
|
xMLHttpRequest = arg1;
|
|
|
|
|
xMLHttpRequest.open("GET", closure_0, true);
|
|
|
|
|
xMLHttpRequest.responseType = "blob";
|
|
|
|
|
xMLHttpRequest.onabort = (arg0) => closure_1(arg0);
|
|
|
|
|
xMLHttpRequest.onerror = (arg0) => closure_1(arg0);
|
|
|
|
|
xMLHttpRequest.ontimeout = (arg0) => closure_1(arg0);
|
|
|
|
|
xMLHttpRequest.onload = () => {
|
|
|
|
|
let data;
|
2026-10-06 22:12:49 +00:00
|
|
|
const tmp = closure_0;
|
2026-09-18 20:18:48 +00:00
|
|
|
if (xMLHttpRequest != null) {
|
|
|
|
|
const response = xMLHttpRequest.response;
|
|
|
|
|
if (response != null) {
|
|
|
|
|
data = response.data;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
return tmp(data);
|
2026-09-18 20:18:48 +00:00
|
|
|
};
|
|
|
|
|
xMLHttpRequest.send();
|
|
|
|
|
});
|
2026-10-06 22:12:49 +00:00
|
|
|
return promise;
|
2026-09-18 20:18:48 +00:00
|
|
|
};
|
|
|
|
|
export const getFileContentLength = function getFileContentLength(arg0) {
|
2026-10-06 22:12:49 +00:00
|
|
|
let closure_0 = arg0;
|
|
|
|
|
const promise = new Promise((arg0, onerror) => {
|
2026-09-18 20:18:48 +00:00
|
|
|
closure_0 = arg0;
|
2026-10-06 22:12:49 +00:00
|
|
|
let closure_1 = onerror;
|
2026-09-18 20:18:48 +00:00
|
|
|
const xMLHttpRequest = new XMLHttpRequest();
|
|
|
|
|
xMLHttpRequest.open("HEAD", closure_0, true);
|
2026-10-06 22:12:49 +00:00
|
|
|
xMLHttpRequest.onload = function() {
|
2026-09-18 20:18:48 +00:00
|
|
|
if (xMLHttpRequest.status >= 200) {
|
2026-10-06 22:12:49 +00:00
|
|
|
if (xMLHttpRequest.status < 300) {
|
2026-09-18 20:18:48 +00:00
|
|
|
const responseHeader = obj.getResponseHeader("Content-Length");
|
|
|
|
|
if (null != responseHeader) {
|
|
|
|
|
if ("" !== responseHeader) {
|
|
|
|
|
const _parseInt = parseInt;
|
|
|
|
|
closure_0(parseInt(responseHeader, 10));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const _Error = Error;
|
2026-10-06 22:12:49 +00:00
|
|
|
const self = this;
|
|
|
|
|
const self2 = this;
|
2026-09-18 20:18:48 +00:00
|
|
|
const error = new Error("Content-Length header is missing");
|
2026-10-06 22:12:49 +00:00
|
|
|
closure_1(error);
|
2026-09-18 20:18:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const error1 = new Error("HTTP request failed with status code " + obj.status);
|
2026-10-06 22:12:49 +00:00
|
|
|
closure_1(error1);
|
2026-09-18 20:18:48 +00:00
|
|
|
};
|
|
|
|
|
xMLHttpRequest.onerror = onerror;
|
|
|
|
|
xMLHttpRequest.onabort = onerror;
|
|
|
|
|
xMLHttpRequest.ontimeout = onerror;
|
|
|
|
|
xMLHttpRequest.send();
|
|
|
|
|
});
|
2026-10-06 22:12:49 +00:00
|
|
|
return promise;
|
2026-09-18 20:18:48 +00:00
|
|
|
};
|
|
|
|
|
export const getFile = function getFile(overrideType) {
|
2026-10-06 22:12:49 +00:00
|
|
|
let i;
|
|
|
|
|
let overrideFilename;
|
|
|
|
|
let str10;
|
|
|
|
|
let str11;
|
|
|
|
|
let str5;
|
|
|
|
|
let uri;
|
2026-09-18 20:18:48 +00:00
|
|
|
({ uri, i, overrideFilename } = overrideType);
|
|
|
|
|
let str = overrideType.overrideType;
|
|
|
|
|
const parts = uri.split("/");
|
|
|
|
|
const parts1 = str2.split("?");
|
|
|
|
|
let str3;
|
|
|
|
|
if (parts1 != null) {
|
|
|
|
|
if (parts1[0] != null) {
|
|
|
|
|
str3 = str4.toLowerCase();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (str3 == null) {
|
|
|
|
|
str3 = "";
|
|
|
|
|
}
|
|
|
|
|
const found = items.find((reName) => {
|
|
|
|
|
reName = reName.reName;
|
|
|
|
|
return reName.test(str3);
|
|
|
|
|
});
|
|
|
|
|
let found1 = found;
|
2026-10-06 22:12:49 +00:00
|
|
|
const arr2 = items;
|
|
|
|
|
const tmp3 = null == found && null != overrideFilename;
|
2026-09-18 20:18:48 +00:00
|
|
|
if (tmp3) {
|
2026-10-06 22:12:49 +00:00
|
|
|
found1 = arr2.find((reName) => {
|
2026-09-18 20:18:48 +00:00
|
|
|
reName = reName.reName;
|
|
|
|
|
return reName.test(overrideFilename);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (null != found1) {
|
|
|
|
|
if (null != overrideFilename) {
|
2026-10-06 22:12:49 +00:00
|
|
|
let combined;
|
|
|
|
|
const str6 = found1.name(i);
|
|
|
|
|
const parts2 = str6.split(".");
|
2026-09-18 20:18:48 +00:00
|
|
|
const arr = parts2.pop();
|
2026-10-06 22:12:49 +00:00
|
|
|
const lastIndexOfResult = overrideFilename.lastIndexOf(".");
|
|
|
|
|
if (-1 !== lastIndexOfResult) {
|
2026-09-18 20:18:48 +00:00
|
|
|
const _HermesInternal2 = HermesInternal;
|
2026-10-06 22:12:49 +00:00
|
|
|
combined = "" + overrideFilename.substr(0, lastIndexOfResult) + "." + arr;
|
2026-09-18 20:18:48 +00:00
|
|
|
} else {
|
|
|
|
|
const _HermesInternal = HermesInternal;
|
|
|
|
|
combined = "" + overrideFilename + "." + arr;
|
|
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
str5 = combined;
|
2026-09-18 20:18:48 +00:00
|
|
|
}
|
2026-10-06 22:12:49 +00:00
|
|
|
const obj = { uri, filename: str5, type: str10, isVideo: -1 !== str11.indexOf("video"), isImage: -1 !== str.indexOf("image") };
|
|
|
|
|
str10 = str;
|
|
|
|
|
if (str == null) {
|
|
|
|
|
let type;
|
|
|
|
|
if (found1 != null) {
|
|
|
|
|
type = found1.type;
|
|
|
|
|
}
|
|
|
|
|
str10 = type;
|
|
|
|
|
}
|
|
|
|
|
if (str10 == null) {
|
|
|
|
|
str10 = "unknown";
|
|
|
|
|
}
|
|
|
|
|
str11 = str;
|
|
|
|
|
if (str == null) {
|
|
|
|
|
let nameResult;
|
|
|
|
|
if (found1 != null) {
|
|
|
|
|
nameResult = found1.name(i);
|
|
|
|
|
}
|
|
|
|
|
str11 = nameResult;
|
|
|
|
|
}
|
|
|
|
|
if (str11 == null) {
|
|
|
|
|
str11 = "";
|
|
|
|
|
}
|
|
|
|
|
if (str == null) {
|
|
|
|
|
let nameResult1;
|
|
|
|
|
if (found1 != null) {
|
|
|
|
|
nameResult1 = found1.name(i);
|
|
|
|
|
}
|
|
|
|
|
str = nameResult1;
|
|
|
|
|
}
|
|
|
|
|
if (str == null) {
|
|
|
|
|
str = "";
|
|
|
|
|
}
|
|
|
|
|
return obj;
|
2026-09-18 20:18:48 +00:00
|
|
|
}
|
|
|
|
|
if (null != found1) {
|
2026-10-06 22:12:49 +00:00
|
|
|
str5 = found1.name(i);
|
2026-09-18 20:18:48 +00:00
|
|
|
} else {
|
|
|
|
|
str5 = overrideFilename;
|
|
|
|
|
if (overrideFilename == null) {
|
|
|
|
|
str5 = "unknown";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|