summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteEditService.ts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-08-02 12:31:35 +0100
committerdakkar <dakkar@thenautilus.net>2024-08-02 12:32:28 +0100
commitb6785804539e547b3b7f38be9e6f705738a7c832 (patch)
treecfcf1dc3ac37b51007fe655d1115eec68b34a0c0 /packages/backend/src/core/NoteEditService.ts
parentMerge remote-tracking branch 'misskey/master' into feature/misskey-2024.07 (diff)
downloadsharkey-b6785804539e547b3b7f38be9e6f705738a7c832.tar.gz
sharkey-b6785804539e547b3b7f38be9e6f705738a7c832.tar.bz2
sharkey-b6785804539e547b3b7f38be9e6f705738a7c832.zip
copy changes from NoteCreateService to NoteEditService
Diffstat (limited to 'packages/backend/src/core/NoteEditService.ts')
-rw-r--r--packages/backend/src/core/NoteEditService.ts27
1 files changed, 16 insertions, 11 deletions
diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts
index 0cb58d04a2..5ff0f26e2b 100644
--- a/packages/backend/src/core/NoteEditService.ts
+++ b/packages/backend/src/core/NoteEditService.ts
@@ -31,7 +31,7 @@ import InstanceChart from '@/core/chart/charts/instance.js';
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { NotificationService } from '@/core/NotificationService.js';
-import { WebhookService } from '@/core/WebhookService.js';
+import { UserWebhookService } from '@/core/UserWebhookService.js';
import { QueueService } from '@/core/QueueService.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
@@ -51,7 +51,6 @@ import { CacheService } from '@/core/CacheService.js';
import { isReply } from '@/misc/is-reply.js';
import { trackPromise } from '@/misc/promise-tracker.js';
import { isUserRelated } from '@/misc/is-user-related.js';
-import { isNotNull } from '@/misc/is-not-null.js';
import { IdentifiableError } from '@/misc/identifiable-error.js';
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention' | 'edited';
@@ -203,7 +202,7 @@ export class NoteEditService implements OnApplicationShutdown {
private notificationService: NotificationService,
private relayService: RelayService,
private federatedInstanceService: FederatedInstanceService,
- private webhookService: WebhookService,
+ private webhookService: UserWebhookService,
private remoteUserResolveService: RemoteUserResolveService,
private apDeliverManagerService: ApDeliverManagerService,
private apRendererService: ApRendererService,
@@ -388,6 +387,9 @@ export class NoteEditService implements OnApplicationShutdown {
mentionedUsers = data.apMentions ?? await this.extractMentionedUsers(user, combinedTokens);
}
+ // if the host is media-silenced, custom emojis are not allowed
+ if (this.utilityService.isMediaSilencedHost(meta.mediaSilencedHosts, user.host)) emojis = [];
+
tags = tags.filter(tag => Array.from(tag ?? '').length <= 128).splice(0, 32);
if (data.reply && (user.id !== data.reply.userId) && !mentionedUsers.some(u => u.id === data.reply!.userId)) {
@@ -631,7 +633,7 @@ export class NoteEditService implements OnApplicationShutdown {
this.webhookService.getActiveWebhooks().then(webhooks => {
webhooks = webhooks.filter(x => x.userId === user.id && x.on.includes('note'));
for (const webhook of webhooks) {
- this.queueService.webhookDeliver(webhook, 'note', {
+ this.queueService.userWebhookDeliver(webhook, 'note', {
note: noteObj,
});
}
@@ -666,7 +668,7 @@ export class NoteEditService implements OnApplicationShutdown {
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === data.reply!.userId && x.on.includes('edited'));
for (const webhook of webhooks) {
- this.queueService.webhookDeliver(webhook, 'edited', {
+ this.queueService.userWebhookDeliver(webhook, 'edited', {
note: noteObj,
});
}
@@ -801,7 +803,7 @@ export class NoteEditService implements OnApplicationShutdown {
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === u.id && x.on.includes('edited'));
for (const webhook of webhooks) {
- this.queueService.webhookDeliver(webhook, 'edited', {
+ this.queueService.userWebhookDeliver(webhook, 'edited', {
note: detailPackedNote,
});
}
@@ -838,7 +840,7 @@ export class NoteEditService implements OnApplicationShutdown {
const mentions = extractMentions(tokens);
let mentionedUsers = (await Promise.all(mentions.map(m =>
this.remoteUserResolveService.resolveUser(m.username, m.host ?? user.host).catch(() => null),
- ))).filter(isNotNull) as MiUser[];
+ ))).filter(x => x !== null) as MiUser[];
// Drop duplicate users
mentionedUsers = mentionedUsers.filter((u, i, self) =>
@@ -933,10 +935,13 @@ export class NoteEditService implements OnApplicationShutdown {
}
}
- if (note.visibility !== 'specified' || !note.visibleUserIds.some(v => v === user.id)) { // 自分自身のHTL
- this.fanoutTimelineService.push(`homeTimeline:${user.id}`, note.id, meta.perUserHomeTimelineCacheMax, r);
- if (note.fileIds.length > 0) {
- this.fanoutTimelineService.push(`homeTimelineWithFiles:${user.id}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r);
+ // 自分自身のHTL
+ if (note.userHost == null) {
+ if (note.visibility !== 'specified' || !note.visibleUserIds.some(v => v === user.id)) {
+ this.fanoutTimelineService.push(`homeTimeline:${user.id}`, note.id, meta.perUserHomeTimelineCacheMax, r);
+ if (note.fileIds.length > 0) {
+ this.fanoutTimelineService.push(`homeTimelineWithFiles:${user.id}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r);
+ }
}
}