diff --git a/CONTRIBUTING.Sharkey.md b/CONTRIBUTING.Sharkey.md index 8e3207f798..943fd8688d 100644 --- a/CONTRIBUTING.Sharkey.md +++ b/CONTRIBUTING.Sharkey.md @@ -358,14 +358,44 @@ seems to do a decent job. - from `.config/example.yml` to `.config/ci.yml` and `chart/files/default.yml` - in `packages/backend/src/core/MfmService.ts`, from `toHtml` to `toMastoApiHtml` - from `verifyLink` in `packages/backend/src/core/activitypub/models/ApPersonService.ts` to `verifyFieldLinks` in `packages/backend/src/misc/verify-field-link.ts` (if sensible) - -- If there have been any changes to the federated user data (the - `renderPerson` function in - `packages/backend/src/core/activitypub/ApRendererService.ts`), make - sure that the set of fields in `userNeedsPublishing` and - `profileNeedsPublishing` in - `packages/backend/src/server/api/endpoints/i/update.ts` are still - correct. +- Check for changes that may require additional work: + - If there have been any changes to the federated user data (the + `renderPerson` function in + `packages/backend/src/core/activitypub/ApRendererService.ts`), make + sure that the set of fields in `userNeedsPublishing` and + `profileNeedsPublishing` in + `packages/backend/src/server/api/endpoints/i/update.ts` are still + correct. + - Check for any new instances of any memory cache class. + (`MemoryKVCache`, `MemorySingleCache`, `RedisKVCache`, `RedisSingleCache`, and `QuantumKVCache` are the current ones.) + These can usually be kept as-is, but all instances must be managed by `CacheManagementService`. + The conversion is easy: + 1. Make sure that `CacheManagementService` is available. + In most cases, it can be injected through DI. + (it's in the `GlobalModule` which should be available everywhere.) + 2. Find where the cache is constructed. + If it's a field initializer, then move it to the constructor (splitting declaration and initialization.) + 3. Replace the `new Whatever()` statement with a call to `cacheManagementService.createWhatever()`. + Arguments can be kept as-is, but remove any references to `Redis`, `InternalEventService`, or `TimeService`. + (these are provided by `CacheManagementService` directly.) + 4. Remove any calls to `dispose()` the cache. + Disposal is managed by `CacheManagementService`, so attempting to call any `dispose` or `onApplicationShutdown` method will produce a type error. + - Check for any new calls to native time functions: + - `Date.now()` - replace with `this.timeService.now`. + Inject `TimeService` via DI if it's not already available. + - `new Date()` - if there's a value passed in, then leave it. + But the no-args constructor should be replaced with `this.timeService.date`. + Inject `TimeService` via DI if it's not already available. + - `setTimeout` - migrate to `this.timeService.startTimer` or `this.timeService.startPromiseTimer`. + The parameters should be the same, but the return type is different. + You may need to replace some `NodeJS.Timeout` types with `this.timerHandle`. + Inject `TimeService` via DI if it's not already available. + - `setInterval` - migrate to `this.timeService.startTimer`. + Migration is mostly the same as `setTimeout`, but with one major difference: + You must add `{ repeated: true }` as the final option parameter. + If this is omitted, the code will compile but the interval will only fire once! + - Check for any new Chart subclasses, and make sure to inject `TimeService` and implement `getCurrentDate`. + - Check for any new Channel subclasses and add all missing DI parameters. - Check the changes against our `develop` branch (`git diff develop`) and against Misskey's `develop` branch (`git diff misskey/develop`).