mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2026-02-04 10:54:12 +02:00
hotfix
This commit is contained in:
@@ -98,14 +98,15 @@ namespace yaflay.ru.Новая_папка
|
||||
JsonNode response = JsonNode.Parse(responseBody);
|
||||
if (response["user"] != null || response["user"]?["id"].ToString() == "945317832290336798")
|
||||
{
|
||||
Author author = new()
|
||||
{
|
||||
discordId = int.Parse(response["user"]["id"].ToString()),
|
||||
discordNickName = response["user"]["display_name"].ToString()
|
||||
};
|
||||
Blogs article = new()
|
||||
{
|
||||
Annotation = body.annotation,
|
||||
author = new Author()
|
||||
{
|
||||
discordId = int.Parse(response["user"]["id"].ToString()),
|
||||
discordNickName = response["user"]["display_name"].ToString()
|
||||
},
|
||||
author = author,
|
||||
dateTime = DateTime.Now,
|
||||
ImageUrl = body.image,
|
||||
Text = body.text,
|
||||
@@ -113,11 +114,11 @@ namespace yaflay.ru.Новая_папка
|
||||
};
|
||||
await Startup.dbContext.Blogs.AddAsync(article);
|
||||
await Startup.dbContext.SaveChangesAsync();
|
||||
return Ok();
|
||||
return Ok(body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Unauthorized();
|
||||
return Unauthorized(body);
|
||||
}
|
||||
}
|
||||
[HttpGet("logout")]
|
||||
@@ -176,5 +177,25 @@ namespace yaflay.ru.Новая_папка
|
||||
}
|
||||
|
||||
}
|
||||
[HttpGet("static/{file}")]
|
||||
public HttpResponseMessage Generate(string file)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
// processing the stream.
|
||||
|
||||
var result = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
Content = new ByteArrayContent(stream.ToArray())
|
||||
};
|
||||
result.Content.Headers.ContentDisposition =
|
||||
new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
|
||||
{
|
||||
FileName = $"wwwroot/static/{file}"
|
||||
};
|
||||
result.Content.Headers.ContentType =
|
||||
new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user