MM-60480: Do not invalidate channel member cache on login (#28143)

On user login, we were aggressively clearing the channel member
cache when it wasn't necessary. There is no channel membership
info that is changing on a user login.

Additionally, we fix some more issues with pointer passing
to the cache. It's a known problem that our value passing
style isn't consistent when we fetch items from cache.
Sometimes we pass pointer-to-pointer, sometimes it's just a
pointer. This is also the reason for https://github.com/mattermost/mattermost/pull/27830.

We fix 2 such cases where we passed pointer-to-pointer
but didn't handle the special case inside the cache.
This time, we actually fix it in the app layer instead
of the cache layer and also add a test for good measure.

https://mattermost.atlassian.net/browse/MM-60480

```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Agniva De Sarker
2024-09-24 13:01:19 +05:30
коммит произвёл GitHub
родитель b6f83c8438
Коммит d45a54a8e9
4 изменённых файлов: 27 добавлений и 9 удалений

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

@@ -65,7 +65,9 @@ func (ps *PlatformService) ClearUserSessionCacheLocal(userID string) {
toPass := make([]any, 0, len(keys))
for i := 0; i < len(keys); i++ {
var session *model.Session
// This always needs to be a pointer to a value.
// Otherwise the msp unmarshaler will fail to work.
var session model.Session
toPass = append(toPass, &session)
}
@@ -77,7 +79,7 @@ func (ps *PlatformService) ClearUserSessionCacheLocal(userID string) {
}
continue
}
gotSession := *(toPass[i].(**model.Session))
gotSession := toPass[i].(*model.Session)
if gotSession == nil {
ps.logger.Warn("Found nil session in ClearUserSessionCacheLocal. This is not expected")
continue