mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-10-26 19:14:12 +00:00 
			
		
		
		
	サーバ起動時にアンテナが非アクティブだった場合、アクティブ化しても再起動するまで反映されない (#12391)
* サーバ起動時にアンテナが非アクティブだった場合、アクティブ化しても再起動するまで反映されない * Fix CHANGELOG.md * lastUsedAtの更新に不備が出るので修正 --------- Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									b5be0e5780
								
							
						
					
					
						commit
						b3d1cc9525
					
				
					 3 changed files with 28 additions and 9 deletions
				
			
		|  | @ -22,6 +22,7 @@ | ||||||
| - fix: 「設定のバックアップ」で一部の項目がバックアップに含まれていなかった問題を修正 | - fix: 「設定のバックアップ」で一部の項目がバックアップに含まれていなかった問題を修正 | ||||||
| 
 | 
 | ||||||
| ### Server | ### Server | ||||||
|  | - Fix: 時間経過により無効化されたアンテナを再有効化したとき、サーバ再起動までその状況が反映されないのを修正 #12303 | ||||||
| - Fix: ロールタイムラインが保存されない問題を修正 | - Fix: ロールタイムラインが保存されない問題を修正 | ||||||
| 
 | 
 | ||||||
| ## 2023.11.1 | ## 2023.11.1 | ||||||
|  |  | ||||||
|  | @ -60,11 +60,21 @@ export class AntennaService implements OnApplicationShutdown { | ||||||
| 						lastUsedAt: new Date(body.lastUsedAt), | 						lastUsedAt: new Date(body.lastUsedAt), | ||||||
| 					}); | 					}); | ||||||
| 					break; | 					break; | ||||||
| 				case 'antennaUpdated': | 				case 'antennaUpdated': { | ||||||
| 					this.antennas[this.antennas.findIndex(a => a.id === body.id)] = { | 					const idx = this.antennas.findIndex(a => a.id === body.id); | ||||||
| 						...body, | 					if (idx >= 0) { | ||||||
| 						lastUsedAt: new Date(body.lastUsedAt), | 						this.antennas[idx] = { | ||||||
| 					}; | 							...body, | ||||||
|  | 							lastUsedAt: new Date(body.lastUsedAt), | ||||||
|  | 						}; | ||||||
|  | 					} else { | ||||||
|  | 						// サーバ起動時にactiveじゃなかった場合、リストに持っていないので追加する必要あり
 | ||||||
|  | 						this.antennas.push({ | ||||||
|  | 							...body, | ||||||
|  | 							lastUsedAt: new Date(body.lastUsedAt), | ||||||
|  | 						}); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
| 					break; | 					break; | ||||||
| 				case 'antennaDeleted': | 				case 'antennaDeleted': | ||||||
| 					this.antennas = this.antennas.filter(a => a.id !== body.id); | 					this.antennas = this.antennas.filter(a => a.id !== body.id); | ||||||
|  |  | ||||||
|  | @ -13,6 +13,7 @@ import { DI } from '@/di-symbols.js'; | ||||||
| import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; | import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; | ||||||
| import { IdService } from '@/core/IdService.js'; | import { IdService } from '@/core/IdService.js'; | ||||||
| import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; | import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; | ||||||
|  | import { GlobalEventService } from '@/core/GlobalEventService.js'; | ||||||
| import { ApiError } from '../../error.js'; | import { ApiError } from '../../error.js'; | ||||||
| 
 | 
 | ||||||
| export const meta = { | export const meta = { | ||||||
|  | @ -71,6 +72,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||||
| 		private queryService: QueryService, | 		private queryService: QueryService, | ||||||
| 		private noteReadService: NoteReadService, | 		private noteReadService: NoteReadService, | ||||||
| 		private funoutTimelineService: FunoutTimelineService, | 		private funoutTimelineService: FunoutTimelineService, | ||||||
|  | 		private globalEventService: GlobalEventService, | ||||||
| 	) { | 	) { | ||||||
| 		super(meta, paramDef, async (ps, me) => { | 		super(meta, paramDef, async (ps, me) => { | ||||||
| 			const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); | 			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); | 				throw new ApiError(meta.errors.noSuchAntenna); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			this.antennasRepository.update(antenna.id, { | 			// falseだった場合はアンテナの配信先が増えたことを通知したい
 | ||||||
| 				isActive: true, | 			const needPublishEvent = !antenna.isActive; | ||||||
| 				lastUsedAt: new Date(), | 
 | ||||||
| 			}); | 			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); | 			let noteIds = await this.funoutTimelineService.get(`antennaTimeline:${antenna.id}`, untilId, sinceId); | ||||||
| 			noteIds = noteIds.slice(0, ps.limit); | 			noteIds = noteIds.slice(0, ps.limit); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue