Merge branch 'master' into advanced-permissions-phase-1
Этот коммит содержится в:
@@ -946,9 +946,9 @@ func (s SqlChannelStore) GetAllChannelMembersNotifyPropsForChannel(channelId str
|
||||
|
||||
var data []allChannelMemberNotifyProps
|
||||
_, err := s.GetReplica().Select(&data, `
|
||||
SELECT ChannelMembers.UserId, ChannelMembers.NotifyProps
|
||||
FROM Channels, ChannelMembers
|
||||
WHERE Channels.Id = ChannelMembers.ChannelId AND ChannelMembers.ChannelId = :ChannelId`, map[string]interface{}{"ChannelId": channelId})
|
||||
SELECT UserId, NotifyProps
|
||||
FROM ChannelMembers
|
||||
WHERE ChannelId = :ChannelId`, map[string]interface{}{"ChannelId": channelId})
|
||||
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlChannelStore.GetAllChannelMembersPropsForChannel", "store.sql_channel.get_members.app_error", nil, "channelId="+channelId+", err="+err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -99,6 +99,7 @@ func (s SqlTeamStore) Update(team *model.Team) store.StoreChannel {
|
||||
team.CreateAt = oldTeam.CreateAt
|
||||
team.UpdateAt = model.GetMillis()
|
||||
team.Name = oldTeam.Name
|
||||
team.LastTeamIconUpdate = oldTeam.LastTeamIconUpdate
|
||||
|
||||
if count, err := s.GetMaster().Update(team); err != nil {
|
||||
result.Err = model.NewAppError("SqlTeamStore.Update", "store.sql_team.update.updating.app_error", nil, "id="+team.Id+", "+err.Error(), http.StatusInternalServerError)
|
||||
@@ -559,3 +560,13 @@ func (s SqlTeamStore) RemoveAllMembersByUser(userId string) store.StoreChannel {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (us SqlTeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
if _, err := us.GetMaster().Exec("UPDATE Teams SET LastTeamIconUpdate = :Time, UpdateAt = :Time WHERE Id = :teamId", map[string]interface{}{"Time": curTime, "teamId": teamId}); err != nil {
|
||||
result.Err = model.NewAppError("SqlTeamStore.UpdateLastTeamIconUpdate", "store.sql_team.update_last_team_icon_update.app_error", nil, "team_id="+teamId, http.StatusInternalServerError)
|
||||
} else {
|
||||
result.Data = teamId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
const (
|
||||
VERSION_4_8_0 = "4.8.0"
|
||||
VERSION_4_7_1 = "4.7.1"
|
||||
VERSION_4_7_0 = "4.7.0"
|
||||
VERSION_4_6_0 = "4.6.0"
|
||||
VERSION_4_5_0 = "4.5.0"
|
||||
@@ -65,6 +66,7 @@ func UpgradeDatabase(sqlStore SqlStore) {
|
||||
UpgradeDatabaseToVersion45(sqlStore)
|
||||
UpgradeDatabaseToVersion46(sqlStore)
|
||||
UpgradeDatabaseToVersion47(sqlStore)
|
||||
UpgradeDatabaseToVersion471(sqlStore)
|
||||
UpgradeDatabaseToVersion48(sqlStore)
|
||||
|
||||
// If the SchemaVersion is empty this this is the first time it has ran
|
||||
@@ -352,6 +354,16 @@ func UpgradeDatabaseToVersion47(sqlStore SqlStore) {
|
||||
}
|
||||
}
|
||||
|
||||
// If any new instances started with 4.7, they would have the bad Email column on the
|
||||
// ChannelMemberHistory table. So for those cases we need to do an upgrade between
|
||||
// 4.7.0 and 4.7.1
|
||||
func UpgradeDatabaseToVersion471(sqlStore SqlStore) {
|
||||
if shouldPerformUpgrade(sqlStore, VERSION_4_7_0, VERSION_4_7_1) {
|
||||
sqlStore.RemoveColumnIfExists("ChannelMemberHistory", "Email")
|
||||
saveSchemaVersion(sqlStore, VERSION_4_7_1)
|
||||
}
|
||||
}
|
||||
|
||||
func UpgradeDatabaseToVersion48(sqlStore SqlStore) {
|
||||
// This version of Mattermost includes an App-Layer migration which migrates from hard-coded roles configured by
|
||||
// a number of parameters in `config.json` to a `Roles` table in the database. The migration code can be seen
|
||||
@@ -359,6 +371,7 @@ func UpgradeDatabaseToVersion48(sqlStore SqlStore) {
|
||||
|
||||
//TODO: Uncomment the following condition when version 4.8.0 is released
|
||||
//if shouldPerformUpgrade(sqlStore, VERSION_4_7_0, VERSION_4_8_0) {
|
||||
sqlStore.CreateColumnIfNotExists("Teams", "LastTeamIconUpdate", "bigint", "bigint", "0")
|
||||
// saveSchemaVersion(sqlStore, VERSION_4_8_0)
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ type TeamStore interface {
|
||||
RemoveMember(teamId string, userId string) StoreChannel
|
||||
RemoveAllMembersByTeam(teamId string) StoreChannel
|
||||
RemoveAllMembersByUser(userId string) StoreChannel
|
||||
UpdateLastTeamIconUpdate(teamId string, curTime int64) StoreChannel
|
||||
}
|
||||
|
||||
type ChannelStore interface {
|
||||
|
||||
@@ -476,3 +476,19 @@ func (_m *TeamStore) UpdateMember(member *model.TeamMember) store.StoreChannel {
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateLastTeamIconUpdate provides a mock function with given fields: teamId
|
||||
func (_m *TeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) store.StoreChannel {
|
||||
ret := _m.Called(teamId)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
||||
r0 = rf(teamId, curTime)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ func TestTeamStore(t *testing.T, ss store.Store) {
|
||||
t.Run("MemberCount", func(t *testing.T) { testTeamStoreMemberCount(t, ss) })
|
||||
t.Run("GetChannelUnreadsForAllTeams", func(t *testing.T) { testGetChannelUnreadsForAllTeams(t, ss) })
|
||||
t.Run("GetChannelUnreadsForTeam", func(t *testing.T) { testGetChannelUnreadsForTeam(t, ss) })
|
||||
t.Run("UpdateLastTeamIconUpdate", func(t *testing.T) { testUpdateLastTeamIconUpdate(t, ss) })
|
||||
}
|
||||
|
||||
func testTeamStoreSave(t *testing.T, ss store.Store) {
|
||||
@@ -1003,3 +1004,28 @@ func testGetChannelUnreadsForTeam(t *testing.T, ss store.Store) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateLastTeamIconUpdate(t *testing.T, ss store.Store) {
|
||||
|
||||
// team icon initially updated a second ago
|
||||
lastTeamIconUpdateInitial := model.GetMillis() - 1000
|
||||
|
||||
o1 := &model.Team{}
|
||||
o1.DisplayName = "Display Name"
|
||||
o1.Name = "z-z-z" + model.NewId() + "b"
|
||||
o1.Email = model.NewId() + "@nowhere.com"
|
||||
o1.Type = model.TEAM_OPEN
|
||||
o1.LastTeamIconUpdate = lastTeamIconUpdateInitial
|
||||
o1 = (<-ss.Team().Save(o1)).Data.(*model.Team)
|
||||
|
||||
curTime := model.GetMillis()
|
||||
|
||||
if err := (<-ss.Team().UpdateLastTeamIconUpdate(o1.Id, curTime)).Err; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ro1 := (<-ss.Team().Get(o1.Id)).Data.(*model.Team)
|
||||
if ro1.LastTeamIconUpdate <= lastTeamIconUpdateInitial {
|
||||
t.Fatal("LastTeamIconUpdate not updated")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user