Fetch post authors when fetching posts (#6400)

This commit is contained in:
Elias Nahum 2022-06-17 14:52:25 -04:00 committed by GitHub
parent 47fe3e2219
commit 86a47e0832
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -410,6 +410,16 @@ export async function fetchPosts(serverUrl: string, channelId: string, page = 0,
actionType: ActionType.POSTS.RECEIVED_SINCE,
prepareRecordsOnly: true,
});
const {authors} = await fetchPostAuthors(serverUrl, result.posts, true);
if (authors?.length) {
const userModels = await operator.handleUsers({
users: authors,
prepareRecordsOnly: true,
});
models.push(...userModels);
}
if (isCRTEnabled) {
const threadModels = await prepareThreadsFromReceivedPosts(operator, result.posts);
if (threadModels?.length) {
@ -515,6 +525,16 @@ export async function fetchPostsSince(serverUrl: string, channelId: string, sinc
actionType: ActionType.POSTS.RECEIVED_SINCE,
prepareRecordsOnly: true,
});
const {authors} = await fetchPostAuthors(serverUrl, result.posts, true);
if (authors?.length) {
const userModels = await operator.handleUsers({
users: authors,
prepareRecordsOnly: true,
});
models.push(...userModels);
}
if (isCRTEnabled) {
const threadModels = await prepareThreadsFromReceivedPosts(operator, result.posts);
if (threadModels?.length) {
@ -624,6 +644,16 @@ export async function fetchPostThread(serverUrl: string, postId: string, fetchOn
actionType: ActionType.POSTS.RECEIVED_IN_THREAD,
prepareRecordsOnly: true,
});
const {authors} = await fetchPostAuthors(serverUrl, result.posts, true);
if (authors?.length) {
const userModels = await operator.handleUsers({
users: authors,
prepareRecordsOnly: true,
});
models.push(...userModels);
}
if (isCRTEnabled) {
const threadModels = await prepareThreadsFromReceivedPosts(operator, result.posts);
if (threadModels?.length) {