GH-10932 Migrate 'Session.UpdateLastActivityAt' to Sync by default (#11078)

* Migrate Session.UpdateLastActivityAt to Sync by default

* GH-10932 fix tests

* GH-10932 update add session code
Этот коммит содержится в:
Marc Argent
2019-06-11 18:40:05 +01:00
коммит произвёл Jesús Espino
родитель cc834e74d4
Коммит b0ad3c10e9
6 изменённых файлов: 23 добавлений и 22 удалений

Просмотреть файл

@@ -223,8 +223,8 @@ func (a *App) UpdateLastActivityAtIfNeeded(session model.Session) {
return
}
if result := <-a.Srv.Store.Session().UpdateLastActivityAt(session.Id, now); result.Err != nil {
mlog.Error(fmt.Sprintf("Failed to update LastActivityAt for user_id=%v and session_id=%v, err=%v", session.UserId, session.Id, result.Err), mlog.String("user_id", session.UserId))
if err := a.Srv.Store.Session().UpdateLastActivityAt(session.Id, now); err != nil {
mlog.Error(fmt.Sprintf("Failed to update LastActivityAt for user_id=%v and session_id=%v, err=%v", session.UserId, session.Id, err), mlog.String("user_id", session.UserId))
}
session.LastActivityAt = now

Просмотреть файл

@@ -56,7 +56,8 @@ func TestGetSessionIdleTimeoutInMinutes(t *testing.T) {
// Test regular session, should timeout
time := session.LastActivityAt - (1000 * 60 * 6)
<-th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
err = th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
require.Nil(t, err)
th.App.ClearSessionCacheForUserSkipClusterSend(session.UserId)
rsession, err = th.App.GetSession(session.Token)
@@ -73,7 +74,8 @@ func TestGetSessionIdleTimeoutInMinutes(t *testing.T) {
session, _ = th.App.CreateSession(session)
time = session.LastActivityAt - (1000 * 60 * 6)
<-th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
err = th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
require.Nil(t, err)
th.App.ClearSessionCacheForUserSkipClusterSend(session.UserId)
_, err = th.App.GetSession(session.Token)
@@ -87,7 +89,8 @@ func TestGetSessionIdleTimeoutInMinutes(t *testing.T) {
session, _ = th.App.CreateSession(session)
time = session.LastActivityAt - (1000 * 60 * 6)
<-th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
err = th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
require.Nil(t, err)
th.App.ClearSessionCacheForUserSkipClusterSend(session.UserId)
_, err = th.App.GetSession(session.Token)
@@ -104,7 +107,8 @@ func TestGetSessionIdleTimeoutInMinutes(t *testing.T) {
session, _ = th.App.CreateSession(session)
time = session.LastActivityAt - (1000 * 60 * 6)
<-th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
err = th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
require.Nil(t, err)
th.App.ClearSessionCacheForUserSkipClusterSend(session.UserId)
_, err = th.App.GetSession(session.Token)