No longer allow duplicate photos

This commit is contained in:
jvyden 2021-12-11 12:15:34 -05:00
commit 69ae0d30ec
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -42,6 +42,14 @@ namespace LBPUnion.ProjectLighthouse.Controllers
Photo? photo = (Photo?)serializer.Deserialize(new StringReader(bodyString));
if (photo == null) return this.BadRequest();
foreach (Photo p in this.database.Photos.Where(p => p.CreatorId == user.UserId))
{
if (p.LargeHash == photo.LargeHash) return this.Ok(); // photo already uplaoded
if (p.MediumHash == photo.MediumHash) return this.Ok();
if (p.SmallHash == photo.SmallHash) return this.Ok();
if (p.PlanHash == photo.PlanHash) return this.Ok();
}
photo.CreatorId = user.UserId;
photo.Creator = user;