MM-52804 - Implement SendPushNotification plugin api method (#24273)
* add SendPushNotification plugin api method * lint; add testing.Short bc of the sleep * add interface and generated layers * add fields to PluginPushNotification; generate mocks * SendPushNotification -> SendPluginPushNotification; improved comments * more comments; fix test * send api.ctx
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f13a531bca
Коммит
8418eefb75
@@ -1266,3 +1266,31 @@ func (api *PluginAPI) GetUploadSession(uploadID string) (*model.UploadSession, e
|
||||
}
|
||||
return fi, nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SendPluginPushNotification(notification *model.PluginPushNotification) error {
|
||||
var profiles map[string]*model.User
|
||||
var err error
|
||||
if notification.Channel.Type == model.ChannelTypeGroup {
|
||||
if profiles, err = api.app.Srv().Store().User().GetAllProfilesInChannel(api.ctx.Context(), notification.Channel.Id, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
sender, appErr := api.app.GetUser(notification.Post.UserId)
|
||||
if appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
user, appErr := api.app.GetUser(notification.UserID)
|
||||
if appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
|
||||
postNotification := &PostNotification{
|
||||
Post: notification.Post,
|
||||
Channel: notification.Channel,
|
||||
ProfileMap: profiles,
|
||||
Sender: sender,
|
||||
}
|
||||
api.app.sendPushNotification(postNotification, user, notification.ExplicitMention, notification.ChannelWideMention, notification.ReplyToThreadType)
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user