[MM-20804] Add "Unarchive Channel" option to the channel info screen (#13349)
* add websocket hooks to restoreChannel * add userId to call in api4 * add constant * undo changes in en.json * add constants to en.json * delete code for deleting webhooks * Update i18n/en.json Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com> * restore channel ordering * delete Props * Update app/channel.go Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com> * Update app/channel.go Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com> * change message format * move WS message right after invalidate * manually reorder en.json entry * reorder en.json * undelete to restore * update en.json ordering * update wording * Update model/post.go Co-Authored-By: Saturnino Abril <saturnino.abril@gmail.com> * Update model/websocket_message.go Co-Authored-By: Saturnino Abril <saturnino.abril@gmail.com> * gofmt * undeleted to restored * add test to success case * delete repeated test Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com> Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com> Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
397e83f870
Коммит
1909fd6607
@@ -605,10 +605,40 @@ func (a *App) postChannelPrivacyMessage(user *model.User, channel *model.Channel
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RestoreChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
|
||||
func (a *App) RestoreChannel(channel *model.Channel, userId string) (*model.Channel, *model.AppError) {
|
||||
if channel.DeleteAt == 0 {
|
||||
return nil, model.NewAppError("restoreChannel", "api.channel.restore_channel.restored.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Channel().Restore(channel.Id, model.GetMillis()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a.InvalidateCacheForChannel(channel)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_RESTORED, channel.TeamId, "", "", nil)
|
||||
message.Add("channel_id", channel.Id)
|
||||
a.Publish(message)
|
||||
|
||||
user, err := a.Srv.Store.User().Get(userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if user != nil {
|
||||
T := utils.GetUserTranslations(user.Locale)
|
||||
|
||||
post := &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Message: T("api.channel.restore_channel.unarchived", map[string]interface{}{"Username": user.Username}),
|
||||
Type: model.POST_CHANNEL_RESTORED,
|
||||
UserId: userId,
|
||||
}
|
||||
|
||||
if _, err := a.CreatePost(post, channel, false); err != nil {
|
||||
mlog.Error("Failed to post unarchive message", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user