diff --git a/keyserver/src/creators/account-creator.js b/keyserver/src/creators/account-creator.js --- a/keyserver/src/creators/account-creator.js +++ b/keyserver/src/creators/account-creator.js @@ -32,7 +32,7 @@ import { createThread } from './thread-creator.js'; import { dbQuery, SQL } from '../database/database.js'; import { deleteCookie } from '../deleters/cookie-deleters.js'; -import { fetchThreadInfos } from '../fetchers/thread-fetchers.js'; +import { fetchAccessibleThreadInfos } from '../fetchers/thread-fetchers.js'; import { fetchLoggedInUserInfo, fetchKnownUserInfos, @@ -145,7 +145,7 @@ const rawMessageInfos = await sendMessagesOnAccountCreation(viewer); const [threadsResult, userInfos, currentUserInfo] = await Promise.all([ - fetchThreadInfos(viewer), + fetchAccessibleThreadInfos(viewer), fetchKnownUserInfos(viewer), fetchLoggedInUserInfo(viewer), ]); diff --git a/keyserver/src/creators/role-creator.js b/keyserver/src/creators/role-creator.js --- a/keyserver/src/creators/role-creator.js +++ b/keyserver/src/creators/role-creator.js @@ -29,7 +29,7 @@ import { createUpdates } from './update-creator.js'; import { dbQuery, SQL } from '../database/database.js'; import { - fetchThreadInfos, + fetchAccessibleThreadInfos, fetchServerThreadInfos, rawThreadInfosFromServerThreadInfos, } from '../fetchers/thread-fetchers.js'; @@ -98,7 +98,7 @@ ): Promise { const { community, name, permissions } = request; - const { threadInfos } = await fetchThreadInfos(viewer, { + const { threadInfos } = await fetchAccessibleThreadInfos(viewer, { threadID: community, }); const threadInfo = threadInfos[community]; diff --git a/keyserver/src/creators/update-creator.js b/keyserver/src/creators/update-creator.js --- a/keyserver/src/creators/update-creator.js +++ b/keyserver/src/creators/update-creator.js @@ -51,7 +51,7 @@ } from '../fetchers/entry-fetchers.js'; import { fetchMessageInfos } from '../fetchers/message-fetchers.js'; import { - fetchThreadInfos, + fetchAccessibleThreadInfos, type FetchThreadInfosResult, } from '../fetchers/thread-fetchers.js'; import { @@ -431,7 +431,7 @@ if (viewerInfo.threadInfos || threadIDsNeedingFetch.size === 0) { return undefined; } - return await fetchThreadInfos(viewer, { + return await fetchAccessibleThreadInfos(viewer, { threadIDs: threadIDsNeedingFetch, }); })(); diff --git a/keyserver/src/deleters/role-deleters.js b/keyserver/src/deleters/role-deleters.js --- a/keyserver/src/deleters/role-deleters.js +++ b/keyserver/src/deleters/role-deleters.js @@ -14,7 +14,7 @@ import { fetchServerThreadInfos, rawThreadInfosFromServerThreadInfos, - fetchThreadInfos, + fetchAccessibleThreadInfos, } from '../fetchers/thread-fetchers.js'; import { checkThreadPermission } from '../fetchers/thread-permission-fetchers.js'; import type { Viewer } from '../session/viewer.js'; @@ -63,7 +63,7 @@ await Promise.all([ dbQuery(defaultRoleQuery), dbQuery(membersWithRoleQuery), - fetchThreadInfos(viewer, { + fetchAccessibleThreadInfos(viewer, { threadID: community, }), ]); diff --git a/keyserver/src/fetchers/thread-fetchers.js b/keyserver/src/fetchers/thread-fetchers.js --- a/keyserver/src/fetchers/thread-fetchers.js +++ b/keyserver/src/fetchers/thread-fetchers.js @@ -254,7 +254,7 @@ }, }; -async function fetchThreadInfos( +async function fetchAccessibleThreadInfos( viewer: Viewer, inputFilter?: FetchThreadInfosFilter, ): Promise { @@ -463,7 +463,7 @@ export { fetchServerThreadInfos, - fetchThreadInfos, + fetchAccessibleThreadInfos, rawThreadInfosFromServerThreadInfos, verifyThreadIDs, verifyThreadID, diff --git a/keyserver/src/fetchers/thread-permission-fetchers.js b/keyserver/src/fetchers/thread-permission-fetchers.js --- a/keyserver/src/fetchers/thread-permission-fetchers.js +++ b/keyserver/src/fetchers/thread-permission-fetchers.js @@ -30,7 +30,7 @@ import type { ThreadType } from 'lib/types/thread-types-enum.js'; import { values } from 'lib/utils/objects.js'; -import { fetchThreadInfos } from './thread-fetchers.js'; +import { fetchAccessibleThreadInfos } from './thread-fetchers.js'; import { fetchKnownUserInfos } from './user-fetchers.js'; import { dbQuery, SQL } from '../database/database.js'; import type { Viewer } from '../session/viewer.js'; @@ -164,7 +164,7 @@ } const [{ threadInfos }, userInfos] = await Promise.all([ - fetchThreadInfos(viewer, { threadIDs: new Set(threadIDs) }), + fetchAccessibleThreadInfos(viewer, { threadIDs: new Set(threadIDs) }), fetchKnownUserInfos(viewer), ]); @@ -177,9 +177,10 @@ communityThreadIDs.add(communityRootThreadID); } - const { threadInfos: communityThreadInfos } = await fetchThreadInfos(viewer, { - threadIDs: communityThreadIDs, - }); + const { threadInfos: communityThreadInfos } = + await fetchAccessibleThreadInfos(viewer, { + threadIDs: communityThreadIDs, + }); const combinedThreadInfos = { ...threadInfos, diff --git a/keyserver/src/responders/redux-state-responders.js b/keyserver/src/responders/redux-state-responders.js --- a/keyserver/src/responders/redux-state-responders.js +++ b/keyserver/src/responders/redux-state-responders.js @@ -41,7 +41,7 @@ import { fetchPrimaryInviteLinks } from '../fetchers/link-fetchers.js'; import { fetchMessageInfos } from '../fetchers/message-fetchers.js'; import { hasAnyNotAcknowledgedPolicies } from '../fetchers/policy-acknowledgment-fetchers.js'; -import { fetchThreadInfos } from '../fetchers/thread-fetchers.js'; +import { fetchAccessibleThreadInfos } from '../fetchers/thread-fetchers.js'; import { fetchCurrentUserInfo, fetchKnownUserInfos, @@ -118,7 +118,7 @@ ? clientUpdatesCurrentAsOf : Date.now(); - const threadInfoPromise = fetchThreadInfos(viewer); + const threadInfoPromise = fetchAccessibleThreadInfos(viewer); const messageInfoPromise = fetchMessageInfos( viewer, messageSelectionCriteria, diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js --- a/keyserver/src/responders/user-responders.js +++ b/keyserver/src/responders/user-responders.js @@ -110,7 +110,7 @@ import { fetchEntryInfos } from '../fetchers/entry-fetchers.js'; import { fetchMessageInfos } from '../fetchers/message-fetchers.js'; import { fetchNotAcknowledgedPolicies } from '../fetchers/policy-acknowledgment-fetchers.js'; -import { fetchThreadInfos } from '../fetchers/thread-fetchers.js'; +import { fetchAccessibleThreadInfos } from '../fetchers/thread-fetchers.js'; import { fetchKnownUserInfos, fetchLoggedInUserInfo, @@ -423,7 +423,7 @@ userInfos, currentUserInfo, ] = await Promise.all([ - fetchThreadInfos(viewer), + fetchAccessibleThreadInfos(viewer), fetchMessageInfos(viewer, messageSelectionCriteria, defaultNumberPerThread), entriesPromise, fetchKnownUserInfos(viewer), diff --git a/keyserver/src/shared/state-sync/threads-state-sync-spec.js b/keyserver/src/shared/state-sync/threads-state-sync-spec.js --- a/keyserver/src/shared/state-sync/threads-state-sync-spec.js +++ b/keyserver/src/shared/state-sync/threads-state-sync-spec.js @@ -11,7 +11,7 @@ import { hash, combineUnorderedHashes, values } from 'lib/utils/objects.js'; import type { ServerStateSyncSpec } from './state-sync-spec.js'; -import { fetchThreadInfos } from '../../fetchers/thread-fetchers.js'; +import { fetchAccessibleThreadInfos } from '../../fetchers/thread-fetchers.js'; import type { Viewer } from '../../session/viewer.js'; import { validateOutput } from '../../utils/validation-utils.js'; @@ -23,7 +23,7 @@ > = Object.freeze({ fetch, async fetchFullSocketSyncPayload(viewer: Viewer) { - const result = await fetchThreadInfos(viewer); + const result = await fetchAccessibleThreadInfos(viewer); return result.threadInfos; }, async fetchServerInfosHash(viewer: Viewer, ids?: $ReadOnlySet) { @@ -37,7 +37,7 @@ async function fetch(viewer: Viewer, ids?: $ReadOnlySet) { const filter = ids ? { threadIDs: ids } : undefined; - const result = await fetchThreadInfos(viewer, filter); + const result = await fetchAccessibleThreadInfos(viewer, filter); return result.threadInfos; } diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js --- a/keyserver/src/updaters/thread-updaters.js +++ b/keyserver/src/updaters/thread-updaters.js @@ -50,7 +50,7 @@ import { fetchMessageInfoByID } from '../fetchers/message-fetchers.js'; import { fetchRoles } from '../fetchers/role-fetchers.js'; import { - fetchThreadInfos, + fetchAccessibleThreadInfos, fetchServerThreadInfos, determineThreadAncestry, rawThreadInfosFromServerThreadInfos, @@ -95,7 +95,7 @@ request.threadID, threadPermissions.CHANGE_ROLE, ), - fetchThreadInfos(viewer, { threadID: request.threadID }), + fetchAccessibleThreadInfos(viewer, { threadID: request.threadID }), ]); if (memberIDs.length === 0) { throw new ServerError('invalid_parameters'); @@ -274,7 +274,7 @@ } const [fetchThreadResult, hasPermission] = await Promise.all([ - fetchThreadInfos(viewer, { threadID: request.threadID }), + fetchAccessibleThreadInfos(viewer, { threadID: request.threadID }), checkThreadPermission( viewer, request.threadID, diff --git a/keyserver/src/updaters/user-subscription-updaters.js b/keyserver/src/updaters/user-subscription-updaters.js --- a/keyserver/src/updaters/user-subscription-updaters.js +++ b/keyserver/src/updaters/user-subscription-updaters.js @@ -10,7 +10,7 @@ import { createUpdates } from '../creators/update-creator.js'; import { dbQuery, SQL } from '../database/database.js'; -import { fetchThreadInfos } from '../fetchers/thread-fetchers.js'; +import { fetchAccessibleThreadInfos } from '../fetchers/thread-fetchers.js'; import type { Viewer } from '../session/viewer.js'; async function userSubscriptionUpdater( @@ -21,7 +21,7 @@ throw new ServerError('not_logged_in'); } - const { threadInfos } = await fetchThreadInfos(viewer, { + const { threadInfos } = await fetchAccessibleThreadInfos(viewer, { threadID: update.threadID, }); const threadInfo = threadInfos[update.threadID];