Revert " PLT-7 adding loc for db calls"
Этот коммит содержится в:
@@ -162,7 +162,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if len(token) != 0 {
|
||||
session := GetSession(c.T, token)
|
||||
session := GetSession(token)
|
||||
|
||||
if session == nil || session.IsExpired() {
|
||||
c.RemoveSessionCookie(w, r)
|
||||
@@ -195,7 +195,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if c.Err == nil && h.isUserActivity && token != "" && len(c.Session.UserId) > 0 {
|
||||
go func() {
|
||||
if err := (<-Srv.Store.User().UpdateUserAndSessionActivity(c.T, c.Session.UserId, c.Session.Id, model.GetMillis())).Err; err != nil {
|
||||
if err := (<-Srv.Store.User().UpdateUserAndSessionActivity(c.Session.UserId, c.Session.Id, model.GetMillis())).Err; err != nil {
|
||||
l4g.Error("Failed to update LastActivityAt for user_id=%v and session_id=%v, err=%v", c.Session.UserId, c.Session.Id, err)
|
||||
}
|
||||
}()
|
||||
@@ -233,7 +233,7 @@ func GetProtocol(r *http.Request) string {
|
||||
|
||||
func (c *Context) LogAudit(extraInfo string) {
|
||||
audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id}
|
||||
if r := <-Srv.Store.Audit().Save(c.T, audit); r.Err != nil {
|
||||
if r := <-Srv.Store.Audit().Save(audit); r.Err != nil {
|
||||
c.LogError(r.Err)
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func (c *Context) LogAuditWithUserId(userId, extraInfo string) {
|
||||
}
|
||||
|
||||
audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id}
|
||||
if r := <-Srv.Store.Audit().Save(c.T, audit); r.Err != nil {
|
||||
if r := <-Srv.Store.Audit().Save(audit); r.Err != nil {
|
||||
c.LogError(r.Err)
|
||||
}
|
||||
}
|
||||
@@ -387,7 +387,7 @@ func (c *Context) setTeamURL(url string, valid bool) {
|
||||
}
|
||||
|
||||
func (c *Context) SetTeamURLFromSession() {
|
||||
if result := <-Srv.Store.Team().Get(c.T, c.Session.TeamId); result.Err == nil {
|
||||
if result := <-Srv.Store.Team().Get(c.Session.TeamId); result.Err == nil {
|
||||
c.setTeamURL(c.GetSiteURL()+"/"+result.Data.(*model.Team).Name, true)
|
||||
}
|
||||
}
|
||||
@@ -515,14 +515,14 @@ func Handle404(w http.ResponseWriter, r *http.Request) {
|
||||
RenderWebError(err, w, r)
|
||||
}
|
||||
|
||||
func GetSession(T goi18n.TranslateFunc, token string) *model.Session {
|
||||
func GetSession(token string) *model.Session {
|
||||
var session *model.Session
|
||||
if ts, ok := sessionCache.Get(token); ok {
|
||||
session = ts.(*model.Session)
|
||||
}
|
||||
|
||||
if session == nil {
|
||||
if sessionResult := <-Srv.Store.Session().Get(T, token); sessionResult.Err != nil {
|
||||
if sessionResult := <-Srv.Store.Session().Get(token); sessionResult.Err != nil {
|
||||
l4g.Error("Invalid session token=" + token + ", err=" + sessionResult.Err.DetailedError)
|
||||
} else {
|
||||
session = sessionResult.Data.(*model.Session)
|
||||
@@ -551,9 +551,9 @@ func GetMultiSessionCookieTokens(r *http.Request) []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func FindMultiSessionForTeamId(T goi18n.TranslateFunc, r *http.Request, teamId string) (int64, *model.Session) {
|
||||
func FindMultiSessionForTeamId(r *http.Request, teamId string) (int64, *model.Session) {
|
||||
for index, token := range GetMultiSessionCookieTokens(r) {
|
||||
s := GetSession(T, token)
|
||||
s := GetSession(token)
|
||||
if s != nil && !s.IsExpired() && s.TeamId == teamId {
|
||||
return int64(index), s
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user