This commit is contained in:
parent
3848f263f3
commit
001f13a804
@ -43,18 +43,6 @@ public abstract class BaseDownloadController : Controller
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (voidFile.Uploader?.IsNostr ?? false)
|
|
||||||
{
|
|
||||||
Response.StatusCode = (int)HttpStatusCode.Redirect;
|
|
||||||
Response.Headers.Location = $"https://files.v0l.io/{voidFile.Metadata.Digest}";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (voidFile.Uploader != default)
|
|
||||||
{
|
|
||||||
voidFile.Uploader = voidFile.Uploader!.PublicProfile ? voidFile.Uploader : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var egressReq = new EgressRequest(gid, GetRanges(Request, (long)voidFile!.Metadata!.Size));
|
var egressReq = new EgressRequest(gid, GetRanges(Request, (long)voidFile!.Metadata!.Size));
|
||||||
if (egressReq.Ranges.Count() > 1)
|
if (egressReq.Ranges.Count() > 1)
|
||||||
{
|
{
|
||||||
@ -102,7 +90,7 @@ public abstract class BaseDownloadController : Controller
|
|||||||
|
|
||||||
protected async Task<VoidFileResponse?> SetupDownload(Guid id)
|
protected async Task<VoidFileResponse?> SetupDownload(Guid id)
|
||||||
{
|
{
|
||||||
var meta = await _fileInfo.Get(id, true);
|
var meta = await _fileInfo.Get(id, false);
|
||||||
if (meta == null)
|
if (meta == null)
|
||||||
{
|
{
|
||||||
Response.StatusCode = 404;
|
Response.StatusCode = 404;
|
||||||
@ -167,6 +155,13 @@ public abstract class BaseDownloadController : Controller
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (meta.IsNostr)
|
||||||
|
{
|
||||||
|
Response.StatusCode = (int)HttpStatusCode.Redirect;
|
||||||
|
Response.Headers.Location = $"https://nostr.download/{meta.Metadata.Digest}";
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
Response.Headers.XFrameOptions = "SAMEORIGIN";
|
Response.Headers.XFrameOptions = "SAMEORIGIN";
|
||||||
Response.Headers.ContentDisposition = $"inline; filename=\"{meta?.Metadata?.Name}\"";
|
Response.Headers.ContentDisposition = $"inline; filename=\"{meta?.Metadata?.Name}\"";
|
||||||
Response.ContentType = meta?.Metadata?.MimeType ?? "application/octet-stream";
|
Response.ContentType = meta?.Metadata?.MimeType ?? "application/octet-stream";
|
||||||
|
@ -48,6 +48,4 @@ public class ApiUser
|
|||||||
/// When the account was created
|
/// When the account was created
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime Created { get; init; }
|
public DateTime Created { get; init; }
|
||||||
|
|
||||||
public bool IsNostr { get; init; }
|
|
||||||
}
|
}
|
||||||
|
@ -375,8 +375,7 @@ public static class Extensions
|
|||||||
NeedsVerification = isSelf ? !u.Flags.HasFlag(UserFlags.EmailVerified) : null,
|
NeedsVerification = isSelf ? !u.Flags.HasFlag(UserFlags.EmailVerified) : null,
|
||||||
PublicProfile = u.Flags.HasFlag(UserFlags.PublicProfile),
|
PublicProfile = u.Flags.HasFlag(UserFlags.PublicProfile),
|
||||||
PublicUploads = u.Flags.HasFlag(UserFlags.PublicUploads),
|
PublicUploads = u.Flags.HasFlag(UserFlags.PublicUploads),
|
||||||
Roles = u.Roles.Select(a => a.Role).ToList(),
|
Roles = u.Roles.Select(a => a.Role).ToList()
|
||||||
IsNostr = u.AuthType is UserAuthType.Nostr
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ public class VoidFileResponse
|
|||||||
public ApiUser? Uploader { get; set; }
|
public ApiUser? Uploader { get; set; }
|
||||||
public Bandwidth? Bandwidth { get; init; }
|
public Bandwidth? Bandwidth { get; init; }
|
||||||
public VirusStatus? VirusScan { get; init; }
|
public VirusStatus? VirusScan { get; init; }
|
||||||
|
public bool IsNostr { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VoidFileMeta
|
public class VoidFileMeta
|
||||||
|
@ -53,7 +53,8 @@ public sealed class FileInfoManager
|
|||||||
Payment = meta.Paywall,
|
Payment = meta.Paywall,
|
||||||
Bandwidth = bandwidth,
|
Bandwidth = bandwidth,
|
||||||
Uploader = user?.Flags.HasFlag(UserFlags.PublicProfile) == true || withEditSecret ? user?.ToApiUser(false) : null,
|
Uploader = user?.Flags.HasFlag(UserFlags.PublicProfile) == true || withEditSecret ? user?.ToApiUser(false) : null,
|
||||||
VirusScan = virusScan?.ToVirusStatus()
|
VirusScan = virusScan?.ToVirusStatus(),
|
||||||
|
IsNostr = user?.AuthType is UserAuthType.Nostr
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user