diff options
Diffstat (limited to 'store')
-rw-r--r-- | store/sqlstore/channel_store.go | 8 | ||||
-rw-r--r-- | store/store.go | 1 | ||||
-rw-r--r-- | store/storetest/mocks/ChannelStore.go | 16 |
3 files changed, 25 insertions, 0 deletions
diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index e158ba5ea..97f60dda0 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -1921,3 +1921,11 @@ func (s SqlChannelStore) ClearAllCustomRoleAssignments() store.StoreChannel { } }) } + +func (s SqlChannelStore) ResetLastPostAt() store.StoreChannel { + return store.Do(func(result *store.StoreResult) { + if _, err := s.GetMaster().Exec("UPDATE Channels SET LastPostAt = (SELECT UpdateAt FROM Posts WHERE ChannelId = Channels.Id ORDER BY UpdateAt DESC LIMIT 1);"); err != nil { + result.Err = model.NewAppError("SqlChannelStore.ResetLastPostAt", "store.sql_channel.reset_last_post_at.app_error", nil, err.Error(), http.StatusInternalServerError) + } + }) +} diff --git a/store/store.go b/store/store.go index 34ba08091..0c89a0a91 100644 --- a/store/store.go +++ b/store/store.go @@ -172,6 +172,7 @@ type ChannelStore interface { MigrateChannelMembers(fromChannelId string, fromUserId string) StoreChannel ResetAllChannelSchemes() StoreChannel ClearAllCustomRoleAssignments() StoreChannel + ResetLastPostAt() StoreChannel } type ChannelMemberHistoryStore interface { diff --git a/store/storetest/mocks/ChannelStore.go b/store/storetest/mocks/ChannelStore.go index 8adc98e10..747a844ec 100644 --- a/store/storetest/mocks/ChannelStore.go +++ b/store/storetest/mocks/ChannelStore.go @@ -711,6 +711,22 @@ func (_m *ChannelStore) ResetAllChannelSchemes() store.StoreChannel { return r0 } +// ResetLastPostAt provides a mock function with given fields: +func (_m *ChannelStore) ResetLastPostAt() store.StoreChannel { + ret := _m.Called() + + var r0 store.StoreChannel + if rf, ok := ret.Get(0).(func() store.StoreChannel); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(store.StoreChannel) + } + } + + return r0 +} + // Restore provides a mock function with given fields: channelId, time func (_m *ChannelStore) Restore(channelId string, time int64) store.StoreChannel { ret := _m.Called(channelId, time) |