[MM-38579] Removing some town square permissions stuff (#18464)

* removing some town square permissions stuff

* fixing error

* adding back in channel leave check

* removing tests

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Этот коммит содержится в:
Ben Cooke
2021-09-27 21:01:16 -04:00
коммит произвёл GitHub
родитель 74054c74bf
Коммит 0332e1545d
5 изменённых файлов: 0 добавлений и 93 удалений

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

@@ -57,30 +57,6 @@ func (a *App) CreatePostAsUser(c *request.Context, post *model.Post, currentSess
err.StatusCode = http.StatusBadRequest
}
if err.Id == "api.post.create_post.town_square_read_only" {
user, nErr := a.Srv().Store.User().Get(context.Background(), post.UserId)
if nErr != nil {
var nfErr *store.ErrNotFound
switch {
case errors.As(nErr, &nfErr):
return nil, model.NewAppError("CreatePostAsUser", MissingAccountError, nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, model.NewAppError("CreatePostAsUser", "app.user.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
}
}
T := i18n.GetUserTranslations(user.Locale)
a.SendEphemeralPost(
post.UserId,
&model.Post{
ChannelId: channel.Id,
RootId: post.RootId,
UserId: post.UserId,
Message: T("api.post.create_post.town_square_read_only"),
CreateAt: model.GetMillis() + 1,
},
)
}
return nil, err
}
@@ -213,13 +189,6 @@ func (a *App) CreatePost(c *request.Context, post *model.Post, channel *model.Ch
post.AddProp("from_bot", "true")
}
if a.Srv().License() != nil &&
!post.IsSystemMessage() &&
channel.Name == model.DefaultChannelName &&
!a.RolesGrantPermission(user.GetRoles(), model.PermissionManageSystem.Id) {
return nil, model.NewAppError("createPost", "api.post.create_post.town_square_read_only", nil, "", http.StatusForbidden)
}
var ephemeralPost *model.Post
if post.Type == "" && !a.HasPermissionToChannel(user.Id, channel.Id, model.PermissionUseChannelMentions) {
mention := post.DisableMentionHighlights()