mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 06:55:54 +01:00
Fix #1516 send noimage.png when user is not exist or removed.
This commit is contained in:
@@ -150,20 +150,21 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
get("/:userName/_avatar"){
|
get("/:userName/_avatar"){
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
|
contentType = "image/png"
|
||||||
getAccountByUserName(userName).map{ account =>
|
getAccountByUserName(userName).map{ account =>
|
||||||
response.setDateHeader("Last-Modified", account.updatedDate.getTime)
|
response.setDateHeader("Last-Modified", account.updatedDate.getTime)
|
||||||
account.image.map{ image =>
|
account.image.map{ image =>
|
||||||
RawData(FileUtil.getMimeType(image), new java.io.File(getUserUploadDir(userName), image))
|
RawData(FileUtil.getMimeType(image), new java.io.File(getUserUploadDir(userName), image))
|
||||||
}.getOrElse{
|
}.getOrElse{
|
||||||
contentType = "image/png"
|
|
||||||
(if (account.isGroupAccount) {
|
(if (account.isGroupAccount) {
|
||||||
TextAvatarUtil.textGroupAvatar(account.fullName)
|
TextAvatarUtil.textGroupAvatar(account.fullName)
|
||||||
} else {
|
} else {
|
||||||
TextAvatarUtil.textAvatar(account.fullName)
|
TextAvatarUtil.textAvatar(account.fullName)
|
||||||
}).getOrElse(Thread.currentThread.getContextClassLoader.getResourceAsStream("noimage.png"))
|
}).get
|
||||||
}
|
}
|
||||||
}.getOrElse{
|
}.getOrElse{
|
||||||
NotFound()
|
response.setHeader("Cache-Control", "max-age=3600")
|
||||||
|
Thread.currentThread.getContextClassLoader.getResourceAsStream("noimage.png")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user