MM-37577 Do not set post id when posting a message (#5602) (#5608)

* MM-37577 Do not set post id when posting a message

* Add unit test to verify that creating a post always send an empty string as the id

(cherry picked from commit 7cdbe095a1)

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Mattermost Build 2021-08-06 17:00:18 +02:00 committed by GitHub
parent c4b48dd647
commit bb26ce5395
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -38,12 +38,14 @@ describe('Actions.Posts', () => {
it('createPost', async () => {
const channelId = TestHelper.basicChannel.id;
const post = TestHelper.fakePost(channelId);
const createPost = jest.spyOn(Client4, 'createPost');
nock(Client4.getBaseRoute()).
post('/posts').
reply(201, {...post, id: TestHelper.generateId()});
await Actions.createPost(post)(store.dispatch, store.getState);
expect(createPost).toHaveBeenCalledWith(expect.objectContaining({id: ''}));
const state = store.getState();
const createRequest = state.requests.posts.createPost;

View file

@ -182,6 +182,7 @@ export function createPost(post: Post, files: any[] = []) {
let newPost = {
...post,
id: '',
pending_post_id: pendingPostId,
create_at: timestamp,
update_at: timestamp,