[MM-55299] Migrate server/channels/app/notification.go to make use of GenericStoreResult (#25746)

* [MM-55299] Make use of GenericStoreResult

Make use of GenericStoreResult in server/channels/app/notification.go

Introduce new result variables to workaround the IncompatibleAssign
error.

* [MM-55299] Make use of GenericStoreResult

Use GenericStoreResult for profiles, cmn properties, groups map.
Introduce new result variables for them to workaround IncompatibleAssign
error.

* Resolve merge conflict. Accept incoming master's change

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Paul Stern
2023-12-18 15:13:56 +03:00
коммит произвёл GitHub
родитель 983062189e
Коммит f69620f22c

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

@@ -627,49 +627,49 @@ func (a *App) RemoveNotifications(c request.CTX, post *model.Post, channel *mode
team = &model.Team{} team = &model.Team{}
} }
pCh := make(chan store.StoreResult, 1) pCh := make(chan store.GenericStoreResult[map[string]*model.User], 1)
go func() { go func() {
props, err := a.Srv().Store().User().GetAllProfilesInChannel(context.Background(), channel.Id, true) props, err := a.Srv().Store().User().GetAllProfilesInChannel(context.Background(), channel.Id, true)
pCh <- store.StoreResult{Data: props, NErr: err} pCh <- store.GenericStoreResult[map[string]*model.User]{Data: props, NErr: err}
close(pCh) close(pCh)
}() }()
cmnCh := make(chan store.StoreResult, 1) cmnCh := make(chan store.GenericStoreResult[map[string]model.StringMap], 1)
go func() { go func() {
props, err := a.Srv().Store().Channel().GetAllChannelMembersNotifyPropsForChannel(channel.Id, true) props, err := a.Srv().Store().Channel().GetAllChannelMembersNotifyPropsForChannel(channel.Id, true)
cmnCh <- store.StoreResult{Data: props, NErr: err} cmnCh <- store.GenericStoreResult[map[string]model.StringMap]{Data: props, NErr: err}
close(cmnCh) close(cmnCh)
}() }()
var gCh chan store.StoreResult var gCh chan store.GenericStoreResult[map[string]*model.Group]
if a.allowGroupMentions(c, post) { if a.allowGroupMentions(c, post) {
gCh = make(chan store.StoreResult, 1) gCh = make(chan store.GenericStoreResult[map[string]*model.Group], 1)
go func() { go func() {
groupsMap, err := a.getGroupsAllowedForReferenceInChannel(channel, team) groupsMap, err := a.getGroupsAllowedForReferenceInChannel(channel, team)
gCh <- store.StoreResult{Data: groupsMap, NErr: err} gCh <- store.GenericStoreResult[map[string]*model.Group]{Data: groupsMap, NErr: err}
close(gCh) close(gCh)
}() }()
} }
result := <-pCh resultP := <-pCh
if result.NErr != nil { if resultP.NErr != nil {
return result.NErr return resultP.NErr
} }
profileMap := result.Data.(map[string]*model.User) profileMap := resultP.Data
result = <-cmnCh resultCmn := <-cmnCh
if result.NErr != nil { if resultCmn.NErr != nil {
return result.NErr return resultCmn.NErr
} }
channelMemberNotifyPropsMap := result.Data.(map[string]model.StringMap) channelMemberNotifyPropsMap := resultCmn.Data
groups := make(map[string]*model.Group) groups := make(map[string]*model.Group)
if gCh != nil { if gCh != nil {
result = <-gCh resultG := <-gCh
if result.NErr != nil { if resultG.NErr != nil {
return result.NErr return resultG.NErr
} }
groups = result.Data.(map[string]*model.Group) groups = resultG.Data
} }
mentions, _ := a.getExplicitMentionsAndKeywords(c, post, channel, profileMap, groups, channelMemberNotifyPropsMap, nil) mentions, _ := a.getExplicitMentionsAndKeywords(c, post, channel, profileMap, groups, channelMemberNotifyPropsMap, nil)