MCPcopy Index your code
hub / github.com/ether/etherpad / computeOutdated

Function computeOutdated

src/node/hooks/express/updateStatus.ts:84–101  ·  view source on GitHub ↗
(
  padId: string | null,
  authorId: string | null,
)

Source from the content-addressed store, hash-verified

82};
83
84const computeOutdated = async (
85 padId: string | null,
86 authorId: string | null,
87): Promise<OutdatedResponse> => {
88 const state = await loadState(stateFilePath());
89 if (!state.latest) return EMPTY;
90 const current = getEpVersion();
91 if (!isMinorOrMoreBehind(current, state.latest.version)) return EMPTY;
92 if (!padId || !authorId) return EMPTY;
93 // padManager is loaded via dynamic import to avoid circular-init w/ updater.
94 const padManagerMod: any = await import('../../db/PadManager');
95 const padManager = padManagerMod.default ?? padManagerMod;
96 if (typeof padManager.isValidPadId !== 'function' || !padManager.isValidPadId(padId)) return EMPTY;
97 if (!(await padManager.doesPadExist(padId))) return EMPTY;
98 const pad = await padManager.getPad(padId);
99 if (firstAuthorOf(pad) !== authorId) return EMPTY;
100 return {outdated: 'minor', isFirstAuthor: true};
101};
102
103// Wrap an async Express handler so a rejected promise becomes next(err) rather than
104// an unhandled rejection. Mirrors the .catch(next) pattern used elsewhere in the repo.

Callers 1

expressCreateServerFunction · 0.85

Calls 5

loadStateFunction · 0.90
stateFilePathFunction · 0.90
getEpVersionFunction · 0.90
isMinorOrMoreBehindFunction · 0.90
firstAuthorOfFunction · 0.85

Tested by

no test coverage detected