( padId: string | null, authorId: string | null, )
| 82 | }; |
| 83 | |
| 84 | const 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. |
no test coverage detected