Add test notification tool (#28334)
* Add test notification tool * Add frontend styles * Remove option from admin view * Refactor create post and add translations * Fix several CI errors * Fix API and frontend snapshots * Refactor trailing and leading icon on buttons * Add different button states * i18n-extract * Fix wrong text * Add tests * Fix wrong string * Fix test * feat: E2E send test notifications (#28371) * Refactor send desktop notification * Address rest of the feedback * Fix tests * Add correct link * Fix test --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: yasserfaraazkhan <attitude3cena.yf@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
30a6ddc995
Коммит
118d0346ee
@@ -242,6 +242,10 @@ func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel
|
||||
post.AddProp(model.PostPropsFromBot, "true")
|
||||
}
|
||||
|
||||
if flags.ForceNotification {
|
||||
post.AddProp(model.PostPropsForceNotification, model.NewId())
|
||||
}
|
||||
|
||||
if c.Session().IsOAuth {
|
||||
post.AddProp(model.PostPropsFromOAuthApp, "true")
|
||||
}
|
||||
@@ -2722,3 +2726,34 @@ func (a *App) CleanUpAfterPostDeletion(c request.CTX, post *model.Post, deleteBy
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendTestMessage(c request.CTX, userID string) (*model.Post, *model.AppError) {
|
||||
bot, err := a.GetSystemBot(c)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SendTestMessage", "app.notifications.send_test_message.errors.no_bot", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
channel, err := a.GetOrCreateDirectChannel(c, userID, bot.UserId)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SendTestMessage", "app.notifications.send_test_message.errors.no_channel", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SendTestMessage", "app.notifications.send_test_message.errors.no_user", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
T := i18n.GetUserTranslations(user.Locale)
|
||||
post := &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Message: T("app.notifications.send_test_message.message_body"),
|
||||
Type: model.PostTypeDefault,
|
||||
UserId: bot.UserId,
|
||||
}
|
||||
|
||||
post, err = a.CreatePost(c, post, channel, model.CreatePostFlags{ForceNotification: true})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SendTestMessage", "app.notifications.send_test_message.errors.create_post", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
return post, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user