mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-03-17 18:12:21 +01:00
Move redirect (again)
This commit is contained in:
parent
3848f263f3
commit
001f13a804
@ -43,18 +43,6 @@ public abstract class BaseDownloadController : Controller
|
||||
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));
|
||||
if (egressReq.Ranges.Count() > 1)
|
||||
{
|
||||
@ -102,7 +90,7 @@ public abstract class BaseDownloadController : Controller
|
||||
|
||||
protected async Task<VoidFileResponse?> SetupDownload(Guid id)
|
||||
{
|
||||
var meta = await _fileInfo.Get(id, true);
|
||||
var meta = await _fileInfo.Get(id, false);
|
||||
if (meta == null)
|
||||
{
|
||||
Response.StatusCode = 404;
|
||||
@ -167,6 +155,13 @@ public abstract class BaseDownloadController : Controller
|
||||
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.ContentDisposition = $"inline; filename=\"{meta?.Metadata?.Name}\"";
|
||||
Response.ContentType = meta?.Metadata?.MimeType ?? "application/octet-stream";
|
||||
|
@ -48,6 +48,4 @@ public class ApiUser
|
||||
/// When the account was created
|
||||
/// </summary>
|
||||
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,
|
||||
PublicProfile = u.Flags.HasFlag(UserFlags.PublicProfile),
|
||||
PublicUploads = u.Flags.HasFlag(UserFlags.PublicUploads),
|
||||
Roles = u.Roles.Select(a => a.Role).ToList(),
|
||||
IsNostr = u.AuthType is UserAuthType.Nostr
|
||||
Roles = u.Roles.Select(a => a.Role).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ public class VoidFileResponse
|
||||
public ApiUser? Uploader { get; set; }
|
||||
public Bandwidth? Bandwidth { get; init; }
|
||||
public VirusStatus? VirusScan { get; init; }
|
||||
public bool IsNostr { get; init; }
|
||||
}
|
||||
|
||||
public class VoidFileMeta
|
||||
|
@ -53,7 +53,8 @@ public sealed class FileInfoManager
|
||||
Payment = meta.Paywall,
|
||||
Bandwidth = bandwidth,
|
||||
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…
x
Reference in New Issue
Block a user