Upgrade http urls to https

This commit is contained in:
Laura Hausmann 2022-11-20 16:57:45 +01:00
parent 840cc49865
commit 11dc5352cb
Signed by: zotan
GPG key ID: D044E84C5BE01605

View file

@ -16,14 +16,17 @@ public class LogPlayback : Controller {
if (token == Token) {
var db = new Database.DbConn();
if (!db.AlbumHistory.Any(p => p.Title == rq.Title && p.Artist == rq.Artist && p.DateTime.Between(DateTime.Now - TimeSpan.FromHours(8), DateTime.Now))) {
if (!db.AlbumHistory.Any() || !(db.AlbumHistory.OrderByDescending(p => p.EntryId).First().Artist == rq.Artist && db.AlbumHistory.OrderByDescending(p => p.EntryId).First().Title == rq.Title)) {
if (!db.AlbumHistory.Any()
|| !(db.AlbumHistory.OrderByDescending(p => p.EntryId).First().Artist == rq.Artist
&& db.AlbumHistory.OrderByDescending(p => p.EntryId).First().Title == rq.Title)) {
var entry = new AlbumHistoryEntry {
Artist = rq.Artist ?? throw new InvalidOperationException(),
Title = rq.Title ?? throw new InvalidOperationException(),
Link = rq.Link ?? throw new InvalidOperationException(),
Source = rq.Source ?? throw new InvalidOperationException(),
Artist = rq.Artist ?? throw new InvalidOperationException(),
Title = rq.Title ?? throw new InvalidOperationException(),
Link = rq.Link ?? throw new InvalidOperationException(),
Source = rq.Source ?? throw new InvalidOperationException(),
DateTime = DateTime.Now
};
entry.Link = entry.Link.StartsWith("http:") ? entry.Link = "https:" + entry.Link[5..] : entry.Link;
db.InsertWithIdentity(entry);
Response.StatusCode = 201;
return entry;