Update channel member notify props to use native JSON (#18114)
* Update channel member notify props to use native JSON Created a new store method that patches the notify props field. https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=91d08676-4a0e-4f02-8dce-d24d4fc56449 ```release-note NONE ``` * cleanup ```release-note NONE ``` * forgot to commit ```release-note NONE ``` * Fix edge case ```release-note NONE ``` * address review comments ```release-note NONE ``` * fix incorrect order ```release-note NONE ``` * Address review comments ```release-note NONE ``` Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c4c1fda128
Коммит
7bbcf86531
@@ -57,6 +57,7 @@ func TestChannelStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||
t.Run("SaveMember", func(t *testing.T) { testChannelSaveMember(t, ss) })
|
||||
t.Run("SaveMultipleMembers", func(t *testing.T) { testChannelSaveMultipleMembers(t, ss) })
|
||||
t.Run("UpdateMember", func(t *testing.T) { testChannelUpdateMember(t, ss) })
|
||||
t.Run("UpdateMemberNotifyProps", func(t *testing.T) { testChannelUpdateMemberNotifyProps(t, ss) })
|
||||
t.Run("UpdateMultipleMembers", func(t *testing.T) { testChannelUpdateMultipleMembers(t, ss) })
|
||||
t.Run("RemoveMember", func(t *testing.T) { testChannelRemoveMember(t, ss) })
|
||||
t.Run("RemoveMembers", func(t *testing.T) { testChannelRemoveMembers(t, ss) })
|
||||
@@ -2955,6 +2956,48 @@ func testChannelUpdateMultipleMembers(t *testing.T, ss store.Store) {
|
||||
})
|
||||
}
|
||||
|
||||
func testChannelUpdateMemberNotifyProps(t *testing.T, ss store.Store) {
|
||||
u1, err := ss.User().Save(&model.User{Username: model.NewId(), Email: MakeEmail()})
|
||||
require.NoError(t, err)
|
||||
defaultNotifyProps := model.GetDefaultChannelNotifyProps()
|
||||
|
||||
team := &model.Team{
|
||||
DisplayName: "Name",
|
||||
Name: NewTestId(),
|
||||
Email: MakeEmail(),
|
||||
Type: model.TeamOpen,
|
||||
}
|
||||
|
||||
team, nErr := ss.Team().Save(team)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
channel := &model.Channel{
|
||||
DisplayName: "DisplayName",
|
||||
Name: NewTestId(),
|
||||
Type: model.ChannelTypeOpen,
|
||||
TeamId: team.Id,
|
||||
}
|
||||
channel, nErr = ss.Channel().Save(channel, -1)
|
||||
require.NoError(t, nErr)
|
||||
defer func() { ss.Channel().PermanentDelete(channel.Id) }()
|
||||
|
||||
member := &model.ChannelMember{
|
||||
ChannelId: channel.Id,
|
||||
UserId: u1.Id,
|
||||
NotifyProps: defaultNotifyProps,
|
||||
}
|
||||
member, nErr = ss.Channel().SaveMember(member)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
props := member.NotifyProps
|
||||
props["hello"] = "world"
|
||||
props[model.DesktopNotifyProp] = model.ChannelNotifyAll
|
||||
member, nErr = ss.Channel().UpdateMemberNotifyProps(member.ChannelId, member.UserId, props)
|
||||
require.NoError(t, nErr)
|
||||
// Verify props.
|
||||
assert.Equal(t, props, member.NotifyProps)
|
||||
}
|
||||
|
||||
func testChannelRemoveMember(t *testing.T, ss store.Store) {
|
||||
u1, err := ss.User().Save(&model.User{Username: model.NewId(), Email: MakeEmail()})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -1907,6 +1907,29 @@ func (_m *ChannelStore) UpdateMember(member *model.ChannelMember) (*model.Channe
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpdateMemberNotifyProps provides a mock function with given fields: channelID, userID, props
|
||||
func (_m *ChannelStore) UpdateMemberNotifyProps(channelID string, userID string, props map[string]string) (*model.ChannelMember, error) {
|
||||
ret := _m.Called(channelID, userID, props)
|
||||
|
||||
var r0 *model.ChannelMember
|
||||
if rf, ok := ret.Get(0).(func(string, string, map[string]string) *model.ChannelMember); ok {
|
||||
r0 = rf(channelID, userID, props)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.ChannelMember)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, string, map[string]string) error); ok {
|
||||
r1 = rf(channelID, userID, props)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpdateMembersRole provides a mock function with given fields: channelID, userIDs
|
||||
func (_m *ChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
|
||||
ret := _m.Called(channelID, userIDs)
|
||||
|
||||
Ссылка в новой задаче
Block a user