Fix at mention that triggers ephemeral message (#6458)

* Fix at mention that triggers ephemeral message

* Properly handle failed posts
This commit is contained in:
Daniel Espino García
2022-07-07 12:12:31 +02:00
committed by GitHub
parent 6a3c600c8a
commit e481c07630
4 changed files with 57 additions and 37 deletions

View File

@@ -52,17 +52,6 @@ export async function handleNewPostEvent(serverUrl: string, msg: WebSocketMessag
return;
}
const models: Model[] = [];
const postModels = await operator.handlePosts({
actionType: ActionType.POSTS.RECEIVED_NEW,
order: [post.id],
posts: [post],
prepareRecordsOnly: true,
});
models.push(...postModels);
const isCRTEnabled = await getIsCRTEnabled(database);
if (isCRTEnabled) {
await createThreadFromNewPost(serverUrl, post, false);
@@ -119,6 +108,8 @@ export async function handleNewPostEvent(serverUrl: string, msg: WebSocketMessag
DeviceEventEmitter.emit(Events.USER_STOP_TYPING, data);
}
const models: Model[] = [];
const {authors} = await fetchPostAuthors(serverUrl, [post], true);
if (authors?.length) {
const authorsModels = await operator.handleUsers({users: authors, prepareRecordsOnly: true});
@@ -176,6 +167,15 @@ export async function handleNewPostEvent(serverUrl: string, msg: WebSocketMessag
}
}
const postModels = await operator.handlePosts({
actionType: ActionType.POSTS.RECEIVED_NEW,
order: [post.id],
posts: [post],
prepareRecordsOnly: true,
});
models.push(...postModels);
operator.batchRecords(models);
}