MCPcopy Create free account
hub / github.com/PaperDebugger/paperdebugger / opGetAllThreads

Function opGetAllThreads

webapp/_webapp/src/libs/overleaf-socket.ts:153–180  ·  view source on GitHub ↗
(
  auth: OverleafAuthentication,
  csrfToken: string,
  projectId: string,
)

Source from the content-addressed store, hash-verified

151// @ts-expect-error - this is a private function
152// eslint-disable-next-line
153async function opGetAllThreads(
154 auth: OverleafAuthentication,
155 csrfToken: string,
156 projectId: string,
157): Promise<Map<string, OverleafThread>> {
158 const currentDomain = window.location.hostname;
159 const res = await fetch(`https://${currentDomain}/project/${projectId}/threads`, {
160 headers: {
161 Accept: "application/json",
162 "Content-Type": "application/json",
163 "X-Csrf-Token": csrfToken,
164 Cookie: `overleaf_session2=${auth.cookieOverleafSession2}; GCLB=${auth.cookieGCLB}`,
165 },
166 });
167
168 if (res.status !== 200) {
169 throw new Error(`HTTP error when fetching threads: ${res.status}`);
170 }
171
172 const json: { [key: string]: OverleafThread } = await res.json();
173 const ret = new Map<string, OverleafThread>();
174
175 Object.entries(json).forEach(([threadId, threadData]) => {
176 ret.set(threadId, threadData as OverleafThread);
177 });
178
179 return ret;
180}
181
182/**
183 * Posts a comment to a thread

Callers

nothing calls this directly

Calls 1

setMethod · 0.45

Tested by

no test coverage detected