Short URL: Update last seen at when visiting a short URL (#28565)

Ref #28248

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
This commit is contained in:
Marcus Efraimsson
2020-10-27 16:16:06 +01:00
committed by GitHub
parent aa9134b3b4
commit 60d40fa99b
3 changed files with 39 additions and 0 deletions

View File

@@ -57,6 +57,11 @@ func (hs *HTTPServer) redirectFromShortURL(c *models.ReqContext) {
return
}
// Failure to update LastSeenAt should still allow to redirect
if err := hs.ShortURLService.UpdateLastSeenAt(c.Req.Context(), shortURL); err != nil {
hs.log.Error("Failed to update short URL last seen at", "error", err)
}
hs.log.Debug("Redirecting short URL", "path", shortURL.Path)
c.Redirect(setting.ToAbsUrl(shortURL.Path), 302)
}