forked from Ivasoft/mattermost-mobile
Fix at mention that triggers ephemeral message (#6458)
* Fix at mention that triggers ephemeral message * Properly handle failed posts
This commit is contained in:
committed by
GitHub
parent
6a3c600c8a
commit
e481c07630
@@ -130,30 +130,9 @@ export async function createPost(serverUrl: string, post: Partial<Post>, files:
|
||||
|
||||
const isCRTEnabled = await getIsCRTEnabled(database);
|
||||
|
||||
let created;
|
||||
try {
|
||||
const created = await client.createPost(newPost);
|
||||
const models = await operator.handlePosts({
|
||||
actionType: ActionType.POSTS.RECEIVED_NEW,
|
||||
order: [created.id],
|
||||
posts: [created],
|
||||
prepareRecordsOnly: true,
|
||||
});
|
||||
const isCrtReply = isCRTEnabled && created.root_id !== '';
|
||||
if (!isCrtReply) {
|
||||
const {member} = await updateLastPostAt(serverUrl, created.channel_id, created.create_at, true);
|
||||
if (member) {
|
||||
models.push(member);
|
||||
}
|
||||
}
|
||||
if (isCRTEnabled) {
|
||||
const {models: threadModels} = await createThreadFromNewPost(serverUrl, created, true);
|
||||
if (threadModels?.length) {
|
||||
models.push(...threadModels);
|
||||
}
|
||||
}
|
||||
await operator.batchRecords(models);
|
||||
|
||||
newPost = created;
|
||||
created = await client.createPost(newPost);
|
||||
} catch (error: any) {
|
||||
const errorPost = {
|
||||
...newPost,
|
||||
@@ -187,8 +166,33 @@ export async function createPost(serverUrl: string, post: Partial<Post>, files:
|
||||
}
|
||||
await operator.batchRecords(models);
|
||||
}
|
||||
|
||||
return {data: true};
|
||||
}
|
||||
|
||||
const models = await operator.handlePosts({
|
||||
actionType: ActionType.POSTS.RECEIVED_NEW,
|
||||
order: [created.id],
|
||||
posts: [created],
|
||||
prepareRecordsOnly: true,
|
||||
});
|
||||
const isCrtReply = isCRTEnabled && created.root_id !== '';
|
||||
if (!isCrtReply) {
|
||||
const {member} = await updateLastPostAt(serverUrl, created.channel_id, created.create_at, true);
|
||||
if (member) {
|
||||
models.push(member);
|
||||
}
|
||||
}
|
||||
if (isCRTEnabled) {
|
||||
const {models: threadModels} = await createThreadFromNewPost(serverUrl, created, true);
|
||||
if (threadModels?.length) {
|
||||
models.push(...threadModels);
|
||||
}
|
||||
}
|
||||
await operator.batchRecords(models);
|
||||
|
||||
newPost = created;
|
||||
|
||||
return {data: true};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user