add attachments
This commit is contained in:
parent
c523d40342
commit
91f8dd0db5
4 changed files with 149 additions and 3 deletions
|
|
@ -24,6 +24,30 @@ public class Program
|
|||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
string stagingDir = $"{LarpixServer.Utils.Utils.ROOMS_DIR}/dms_staging";
|
||||
if (Directory.Exists(stagingDir))
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(stagingDir))
|
||||
{
|
||||
var fileInfo = new FileInfo(file);
|
||||
var age = DateTime.UtcNow - fileInfo.LastWriteTimeUtc;
|
||||
var remaining = TimeSpan.FromMinutes(10) - age;
|
||||
if (remaining <= TimeSpan.Zero)
|
||||
{
|
||||
Fs.DeleteFile(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(remaining);
|
||||
if (Fs.Exists(file)) Fs.DeleteFile(file);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.UseWebSockets();
|
||||
|
||||
app.Use(async (HttpContext context, Func<Task> next) =>
|
||||
|
|
@ -191,6 +215,12 @@ public class Program
|
|||
case "/_larpix/upload":
|
||||
await Account.Requests.Upload(context, next, query);
|
||||
return;
|
||||
case "/_larpix/dm/attachment/staging":
|
||||
await Account.Requests.UploadDmAttachmentStaging(context, next, query);
|
||||
return;
|
||||
case "/_larpix/dm/attachment/get":
|
||||
await Account.Requests.GetDmAttachment(context, next, query);
|
||||
return;
|
||||
case "/_larpix/federation":
|
||||
await Federation.Receiver.FederationRequest(context, next, query, reader);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue