PLT-1909 Removed the ability to edit system posts (#3013)
* Removed the ability to edit system posts * Added increased timeout to SpinnerButton unit tests
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
5580c28e54
Коммит
0fe75cb782
@@ -919,6 +919,12 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.Err.StatusCode = http.StatusForbidden
|
||||
return
|
||||
}
|
||||
|
||||
if oldPost.IsSystemMessage() {
|
||||
c.Err = model.NewLocAppError("updatePost", "api.post.update_post.system_message.app_error", nil, "id="+post.Id)
|
||||
c.Err.StatusCode = http.StatusForbidden
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
hashtags, _ := model.ParseHashtags(post.Message)
|
||||
|
||||
@@ -155,6 +155,17 @@ func TestUpdatePost(t *testing.T) {
|
||||
t.Fatal("failed to updates")
|
||||
}
|
||||
}
|
||||
|
||||
post3 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", Type: model.POST_JOIN_LEAVE}
|
||||
rpost3, err := Client.CreatePost(post3)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
up3 := &model.Post{Id: rpost3.Data.(*model.Post).Id, ChannelId: channel1.Id, Message: "a" + model.NewId() + " update post 3"}
|
||||
if _, err := Client.UpdatePost(up3); err == nil {
|
||||
t.Fatal("shouldn't have been able to update system message")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPosts(t *testing.T) {
|
||||
|
||||
@@ -935,6 +935,10 @@
|
||||
"id": "api.post.update_post.permissions_details.app_error",
|
||||
"translation": "Already deleted id={{.PostId}}"
|
||||
},
|
||||
{
|
||||
"id": "api.post.update_post.system_message.app_error",
|
||||
"translation": "Unable to update system message"
|
||||
},
|
||||
{
|
||||
"id": "api.post_get_post_by_id.get.app_error",
|
||||
"translation": "Unable to get post"
|
||||
|
||||
@@ -33,6 +33,7 @@ export default class PostInfo extends React.Component {
|
||||
var post = this.props.post;
|
||||
var isOwner = this.props.currentUser.id === post.user_id;
|
||||
var isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser();
|
||||
const isSystemMessage = post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX);
|
||||
|
||||
if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING || Utils.isPostEphemeral(post)) {
|
||||
return '';
|
||||
@@ -108,7 +109,7 @@ export default class PostInfo extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
if (isOwner) {
|
||||
if (isOwner && !isSystemMessage) {
|
||||
dropdownContents.push(
|
||||
<li
|
||||
key='editPost'
|
||||
|
||||
@@ -85,6 +85,7 @@ export default class RhsComment extends React.Component {
|
||||
|
||||
const isOwner = this.props.currentUser.id === post.user_id;
|
||||
var isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser();
|
||||
const isSystemMessage = post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX);
|
||||
|
||||
var dropdownContents = [];
|
||||
|
||||
@@ -107,7 +108,7 @@ export default class RhsComment extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
if (isOwner) {
|
||||
if (isOwner && !isSystemMessage) {
|
||||
dropdownContents.push(
|
||||
<li
|
||||
role='presentation'
|
||||
|
||||
@@ -41,6 +41,7 @@ export default class RhsRootPost extends React.Component {
|
||||
const user = this.props.user;
|
||||
var isOwner = this.props.currentUser.id === post.user_id;
|
||||
var isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser();
|
||||
const isSystemMessage = post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX);
|
||||
var timestamp = UserStore.getProfile(post.user_id).update_at;
|
||||
var channel = ChannelStore.get(post.channel_id);
|
||||
|
||||
@@ -94,7 +95,7 @@ export default class RhsRootPost extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
if (isOwner) {
|
||||
if (isOwner && !isSystemMessage) {
|
||||
dropdownContents.push(
|
||||
<li
|
||||
key='rhs-root-edit'
|
||||
|
||||
@@ -6,6 +6,7 @@ import SpinnerButton from '../components/spinner_button.jsx';
|
||||
import React from 'react';
|
||||
|
||||
describe('SpinnerButton', function() {
|
||||
this.timeout(10000);
|
||||
jsdom();
|
||||
|
||||
it('check props', function() {
|
||||
|
||||
Ссылка в новой задаче
Block a user