summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/MetaService.ts
diff options
context:
space:
mode:
authoranatawa12 <anatawa12@icloud.com>2023-12-21 11:34:19 +0900
committerGitHub <noreply@github.com>2023-12-21 11:34:19 +0900
commitb2254a66d32bf553a16af3b584e6c5a69e64efc4 (patch)
treec5ff3094887fa5f6d04295ae592148dd2aa3b82b /packages/backend/src/core/MetaService.ts
parentUpdate CHANGELOG.md (diff)
downloadsharkey-b2254a66d32bf553a16af3b584e6c5a69e64efc4.tar.gz
sharkey-b2254a66d32bf553a16af3b584e6c5a69e64efc4.tar.bz2
sharkey-b2254a66d32bf553a16af3b584e6c5a69e64efc4.zip
chore: remove hashtag from featured immediately (#12668)
* chore: remove hashtag from featured immediately * docs(changelog): ハッシュタグのトレンド除外設定が即時に効果を持つように修正 --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/backend/src/core/MetaService.ts')
-rw-r--r--packages/backend/src/core/MetaService.ts25
1 files changed, 22 insertions, 3 deletions
diff --git a/packages/backend/src/core/MetaService.ts b/packages/backend/src/core/MetaService.ts
index 508544dc07..80e8020961 100644
--- a/packages/backend/src/core/MetaService.ts
+++ b/packages/backend/src/core/MetaService.ts
@@ -11,6 +11,7 @@ import { MiMeta } from '@/models/Meta.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { bindThis } from '@/decorators.js';
import type { GlobalEvents } from '@/core/GlobalEventService.js';
+import { FeaturedService } from '@/core/FeaturedService.js';
import type { OnApplicationShutdown } from '@nestjs/common';
@Injectable()
@@ -25,6 +26,7 @@ export class MetaService implements OnApplicationShutdown {
@Inject(DI.db)
private db: DataSource,
+ private featuredService: FeaturedService,
private globalEventService: GlobalEventService,
) {
//this.onMessage = this.onMessage.bind(this);
@@ -95,6 +97,8 @@ export class MetaService implements OnApplicationShutdown {
@bindThis
public async update(data: Partial<MiMeta>): Promise<MiMeta> {
+ let before: MiMeta | undefined;
+
const updated = await this.db.transaction(async transactionalEntityManager => {
const metas = await transactionalEntityManager.find(MiMeta, {
order: {
@@ -102,10 +106,10 @@ export class MetaService implements OnApplicationShutdown {
},
});
- const meta = metas[0];
+ before = metas[0];
- if (meta) {
- await transactionalEntityManager.update(MiMeta, meta.id, data);
+ if (before) {
+ await transactionalEntityManager.update(MiMeta, before.id, data);
const metas = await transactionalEntityManager.find(MiMeta, {
order: {
@@ -119,6 +123,21 @@ export class MetaService implements OnApplicationShutdown {
}
});
+ if (data.hiddenTags) {
+ process.nextTick(() => {
+ const hiddenTags = new Set<string>(data.hiddenTags);
+ if (before) {
+ for (const previousHiddenTag of before.hiddenTags) {
+ hiddenTags.delete(previousHiddenTag);
+ }
+ }
+
+ for (const hiddenTag of hiddenTags) {
+ this.featuredService.removeHashtagsFromRanking(hiddenTag);
+ }
+ });
+ }
+
this.globalEventService.publishInternalEvent('metaUpdated', updated);
return updated;