MM-53924 - Implement push notifications plugin hook and plugin api method (#24350)
* Revert "MM-52804 - Implement SendPushNotification plugin api method (#24273)" This reverts commit8418eefb75. * Revert "MM-53924 - Implement NotificationWillBePushed plugin hook (#24263)" This reverts commitf13a531bca. * implement NotificationWillBePushed plugin hook * implement SendPushNotification plugin api method * move where we're setting post and channel type * fix comment --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
dad579daee
Коммит
69c11cfe14
@@ -1267,30 +1267,7 @@ 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
|
||||
func (api *PluginAPI) SendPushNotification(notification *model.PushNotification, userID string) *model.AppError {
|
||||
// Ignoring skipSessionId because it's only used internally to clear push notifications
|
||||
return api.app.sendPushNotificationToAllSessions(notification, userID, "")
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user