mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 02:42:28 +00:00
Merge pull request #1228 from PR0M3TH3AN/r2-imeta-fix-13043697172182060536
fix: ensure infohash is included in r2 upload imeta tags
This commit is contained in:
1 file changed
+21
-3
@@ -117,7 +117,10 @@ class R2Service {
|
||||
this.emit("uploadProgress", { fraction });
|
||||
}
|
||||
|
||||
buildNip71MetadataForUpload(existingMetadata, { publicUrl = "", file = null } = {}) {
|
||||
buildNip71MetadataForUpload(
|
||||
existingMetadata,
|
||||
{ publicUrl = "", file = null, infoHash = "" } = {},
|
||||
) {
|
||||
const base =
|
||||
existingMetadata && typeof existingMetadata === "object"
|
||||
? { ...existingMetadata }
|
||||
@@ -168,8 +171,13 @@ class R2Service {
|
||||
|
||||
const primaryVariant = imetaList[0];
|
||||
const normalizedUrl =
|
||||
typeof publicUrl === "string" ? publicUrl.trim() : String(publicUrl || "").trim();
|
||||
if (normalizedUrl && (!primaryVariant.url || !String(primaryVariant.url).trim())) {
|
||||
typeof publicUrl === "string"
|
||||
? publicUrl.trim()
|
||||
: String(publicUrl || "").trim();
|
||||
if (
|
||||
normalizedUrl &&
|
||||
(!primaryVariant.url || !String(primaryVariant.url).trim())
|
||||
) {
|
||||
primaryVariant.url = normalizedUrl;
|
||||
}
|
||||
|
||||
@@ -179,6 +187,15 @@ class R2Service {
|
||||
primaryVariant.m = mimeType;
|
||||
}
|
||||
|
||||
const normalizedHash =
|
||||
typeof infoHash === "string" ? infoHash.trim().toLowerCase() : "";
|
||||
if (
|
||||
normalizedHash &&
|
||||
(!primaryVariant.x || !String(primaryVariant.x).trim())
|
||||
) {
|
||||
primaryVariant.x = normalizedHash;
|
||||
}
|
||||
|
||||
base.imeta = imetaList;
|
||||
|
||||
return base;
|
||||
@@ -688,6 +705,7 @@ class R2Service {
|
||||
const mergedNip71 = this.buildNip71MetadataForUpload(metadata?.nip71, {
|
||||
publicUrl,
|
||||
file,
|
||||
infoHash,
|
||||
});
|
||||
if (mergedNip71 && Object.keys(mergedNip71).length) {
|
||||
rawVideoPayload.nip71 = mergedNip71;
|
||||
|
||||
Reference in new issue
Block a user