[MM-25659] ability to permanent delete channel through client (#15202)

Summary

    Ability to permanent delete channel through client

Ticket Link

    https://mattermost.atlassian.net/browse/MM-25659
Этот коммит содержится в:
Ashish Bhate
2020-08-14 08:42:39 +00:00
коммит произвёл GitHub
родитель 11513a8d0d
Коммит d76039db23
7 изменённых файлов: 113 добавлений и 2 удалений

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

@@ -15,7 +15,7 @@ func (api *API) InitChannelLocal() {
api.BaseRoutes.Channels.Handle("", api.ApiLocal(localCreateChannel)).Methods("POST")
api.BaseRoutes.Channel.Handle("", api.ApiLocal(getChannel)).Methods("GET")
api.BaseRoutes.ChannelByName.Handle("", api.ApiLocal(getChannelByName)).Methods("GET")
api.BaseRoutes.Channel.Handle("", api.ApiLocal(deleteChannel)).Methods("DELETE")
api.BaseRoutes.Channel.Handle("", api.ApiLocal(localDeleteChannel)).Methods("DELETE")
api.BaseRoutes.Channel.Handle("/patch", api.ApiLocal(localPatchChannel)).Methods("PUT")
api.BaseRoutes.Channel.Handle("/move", api.ApiLocal(localMoveChannel)).Methods("POST")
@@ -277,3 +277,40 @@ func localMoveChannel(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(channel.ToJson()))
}
func localDeleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireChannelId()
if c.Err != nil {
return
}
channel, err := c.App.GetChannel(c.Params.ChannelId)
if err != nil {
c.Err = err
return
}
auditRec := c.MakeAuditRecord("localDeleteChannel", audit.Fail)
defer c.LogAuditRec(auditRec)
auditRec.AddMeta("channeld", channel)
if channel.Type == model.CHANNEL_DIRECT || channel.Type == model.CHANNEL_GROUP {
c.Err = model.NewAppError("localDeleteChannel", "api.channel.delete_channel.type.invalid", nil, "", http.StatusBadRequest)
return
}
if c.Params.Permanent {
err = c.App.PermanentDeleteChannel(channel)
} else {
err = c.App.DeleteChannel(channel, "")
}
if err != nil {
c.Err = err
return
}
auditRec.Success()
c.LogAudit("name=" + channel.Name)
ReturnStatusOK(w)
}