サーバ起動時にアンテナが非アクティブだった場合、アクティブ化しても再起動するまで反映されない (#12391)

* サーバ起動時にアンテナが非アクティブだった場合、アクティブ化しても再起動するまで反映されない

* Fix CHANGELOG.md

* lastUsedAtの更新に不備が出るので修正

---------

Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com>
This commit is contained in:
おさむのひと 2023-11-21 15:32:34 +09:00 committed by GitHub
parent b5be0e5780
commit b3d1cc9525
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 9 deletions

View file

@ -13,6 +13,7 @@ import { DI } from '@/di-symbols.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { IdService } from '@/core/IdService.js';
import { FunoutTimelineService } from '@/core/FunoutTimelineService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { ApiError } from '../../error.js';
export const meta = {
@ -71,6 +72,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private queryService: QueryService,
private noteReadService: NoteReadService,
private funoutTimelineService: FunoutTimelineService,
private globalEventService: GlobalEventService,
) {
super(meta, paramDef, async (ps, me) => {
const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null);
@ -85,10 +87,16 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.noSuchAntenna);
}
this.antennasRepository.update(antenna.id, {
isActive: true,
lastUsedAt: new Date(),
});
// falseだった場合はアンテナの配信先が増えたことを通知したい
const needPublishEvent = !antenna.isActive;
antenna.isActive = true;
antenna.lastUsedAt = new Date();
this.antennasRepository.update(antenna.id, antenna);
if (needPublishEvent) {
this.globalEventService.publishInternalEvent('antennaUpdated', antenna);
}
let noteIds = await this.funoutTimelineService.get(`antennaTimeline:${antenna.id}`, untilId, sinceId);
noteIds = noteIds.slice(0, ps.limit);