MM-56083 Add PatchMultipleMembersNotifyProps plugin API (#25690)

* Add ChannelStore.UpdateMultipleMembersNotifyProps

* Make UpdateMultipleMembersNotifyProps return updated values from the DB

* Add UpdateChannelMembersNotifications plugin API

* Extract i18n

* Fix style

* Make layers

* Change to PatchMultipleMembersNotifyProps

* Add limit to PatchChannelMembersNotifyProps

* Add additional unit tests

* Address feedback

* Lowercase decodeJSON

* Have PatchMultipleMembersNotifyProps update LastUpdateAt

* Fix tests that relied on unreliable return order

* Fix i18n
Этот коммит содержится в:
Harrison Healey
2024-01-11 13:24:52 -05:00
коммит произвёл GitHub
родитель aafe7439af
Коммит 4d96c11314
21 изменённых файлов: 780 добавлений и 37 удалений

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

@@ -600,6 +600,15 @@ type API interface {
// Minimum server version: 5.2
UpdateChannelMemberNotifications(channelId, userID string, notifications map[string]string) (*model.ChannelMember, *model.AppError)
// PatchChannelMembersNotifications updates the notification properties for multiple channel members.
// Other changes made to the channel memberships will be ignored. A maximum of 200 members can be
// updated at once.
//
// @tag Channel
// @tag User
// Minimum server version: 9.5
PatchChannelMembersNotifications(members []*model.ChannelMemberIdentifier, notifyProps map[string]string) *model.AppError
// GetGroup gets a group by ID.
//
// @tag Group

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

@@ -657,6 +657,13 @@ func (api *apiTimerLayer) UpdateChannelMemberNotifications(channelId, userID str
return _returnsA, _returnsB
}
func (api *apiTimerLayer) PatchChannelMembersNotifications(members []*model.ChannelMemberIdentifier, notifyProps map[string]string) *model.AppError {
startTime := timePkg.Now()
_returnsA := api.apiImpl.PatchChannelMembersNotifications(members, notifyProps)
api.recordTime(startTime, "PatchChannelMembersNotifications", _returnsA == nil)
return _returnsA
}
func (api *apiTimerLayer) GetGroup(groupId string) (*model.Group, *model.AppError) {
startTime := timePkg.Now()
_returnsA, _returnsB := api.apiImpl.GetGroup(groupId)

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

@@ -3663,6 +3663,35 @@ func (s *apiRPCServer) UpdateChannelMemberNotifications(args *Z_UpdateChannelMem
return nil
}
type Z_PatchChannelMembersNotificationsArgs struct {
A []*model.ChannelMemberIdentifier
B map[string]string
}
type Z_PatchChannelMembersNotificationsReturns struct {
A *model.AppError
}
func (g *apiRPCClient) PatchChannelMembersNotifications(members []*model.ChannelMemberIdentifier, notifyProps map[string]string) *model.AppError {
_args := &Z_PatchChannelMembersNotificationsArgs{members, notifyProps}
_returns := &Z_PatchChannelMembersNotificationsReturns{}
if err := g.client.Call("Plugin.PatchChannelMembersNotifications", _args, _returns); err != nil {
log.Printf("RPC call to PatchChannelMembersNotifications API failed: %s", err.Error())
}
return _returns.A
}
func (s *apiRPCServer) PatchChannelMembersNotifications(args *Z_PatchChannelMembersNotificationsArgs, returns *Z_PatchChannelMembersNotificationsReturns) error {
if hook, ok := s.impl.(interface {
PatchChannelMembersNotifications(members []*model.ChannelMemberIdentifier, notifyProps map[string]string) *model.AppError
}); ok {
returns.A = hook.PatchChannelMembersNotifications(args.A, args.B)
} else {
return encodableError(fmt.Errorf("API PatchChannelMembersNotifications called but not implemented."))
}
return nil
}
type Z_GetGroupArgs struct {
A string
}

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

@@ -3226,6 +3226,22 @@ func (_m *API) PatchBot(botUserId string, botPatch *model.BotPatch) (*model.Bot,
return r0, r1
}
// PatchChannelMembersNotifications provides a mock function with given fields: members, notifyProps
func (_m *API) PatchChannelMembersNotifications(members []*model.ChannelMemberIdentifier, notifyProps map[string]string) *model.AppError {
ret := _m.Called(members, notifyProps)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func([]*model.ChannelMemberIdentifier, map[string]string) *model.AppError); ok {
r0 = rf(members, notifyProps)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
}
return r0
}
// PermanentDeleteBot provides a mock function with given fields: botUserId
func (_m *API) PermanentDeleteBot(botUserId string) *model.AppError {
ret := _m.Called(botUserId)