[backend/api] Fix edge case where GetAvatar and GetBanner can be both IsAvatar and IsBanner
This commit is contained in:
parent
6322d5fb91
commit
16a0a76528
1 changed files with 8 additions and 4 deletions
|
@ -117,6 +117,8 @@ public class ProfileController(
|
||||||
var user = HttpContext.GetUserOrFail();
|
var user = HttpContext.GetUserOrFail();
|
||||||
|
|
||||||
var file = await db.DriveFiles
|
var file = await db.DriveFiles
|
||||||
|
.Include(p => p.UserAvatar)
|
||||||
|
.Include(p => p.UserBanner)
|
||||||
.FirstOrDefaultAsync(p => p.UserId == user.Id && p.UserAvatar != null)
|
.FirstOrDefaultAsync(p => p.UserId == user.Id && p.UserAvatar != null)
|
||||||
?? throw GracefulException.RecordNotFound();
|
?? throw GracefulException.RecordNotFound();
|
||||||
|
|
||||||
|
@ -129,8 +131,8 @@ public class ProfileController(
|
||||||
ContentType = file.Type,
|
ContentType = file.Type,
|
||||||
Sensitive = file.IsSensitive,
|
Sensitive = file.IsSensitive,
|
||||||
Description = file.Comment,
|
Description = file.Comment,
|
||||||
IsAvatar = true,
|
IsAvatar = file.UserAvatar != null,
|
||||||
IsBanner = false
|
IsBanner = file.UserBanner != null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +191,8 @@ public class ProfileController(
|
||||||
var user = HttpContext.GetUserOrFail();
|
var user = HttpContext.GetUserOrFail();
|
||||||
|
|
||||||
var file = await db.DriveFiles
|
var file = await db.DriveFiles
|
||||||
|
.Include(p => p.UserAvatar)
|
||||||
|
.Include(p => p.UserBanner)
|
||||||
.FirstOrDefaultAsync(p => p.UserId == user.Id && p.UserBanner != null)
|
.FirstOrDefaultAsync(p => p.UserId == user.Id && p.UserBanner != null)
|
||||||
?? throw GracefulException.RecordNotFound();
|
?? throw GracefulException.RecordNotFound();
|
||||||
|
|
||||||
|
@ -201,8 +205,8 @@ public class ProfileController(
|
||||||
ContentType = file.Type,
|
ContentType = file.Type,
|
||||||
Sensitive = file.IsSensitive,
|
Sensitive = file.IsSensitive,
|
||||||
Description = file.Comment,
|
Description = file.Comment,
|
||||||
IsAvatar = false,
|
IsAvatar = file.UserAvatar != null,
|
||||||
IsBanner = true
|
IsBanner = file.UserBanner != null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue