summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteCreateService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-03-22 09:55:38 +0900
committerGitHub <noreply@github.com>2023-03-22 09:55:38 +0900
commit1e67e9c6616c6e87ae85ece71e5401006df2dd34 (patch)
treea0d6df03a3d0ac2edf1fda7ed4bfb789b5a29720 /packages/backend/src/core/NoteCreateService.ts
parentMerge pull request #10218 from misskey-dev/develop (diff)
parentfix drive-cleaner (diff)
downloadmisskey-1e67e9c6616c6e87ae85ece71e5401006df2dd34.tar.gz
misskey-1e67e9c6616c6e87ae85ece71e5401006df2dd34.tar.bz2
misskey-1e67e9c6616c6e87ae85ece71e5401006df2dd34.zip
Merge pull request #10342 from misskey-dev/develop
Release: 13.10.0
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
-rw-r--r--packages/backend/src/core/NoteCreateService.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts
index 4c4261ba79..2fc2a3d54f 100644
--- a/packages/backend/src/core/NoteCreateService.ts
+++ b/packages/backend/src/core/NoteCreateService.ts
@@ -30,7 +30,7 @@ import PerUserNotesChart from '@/core/chart/charts/per-user-notes.js';
import InstanceChart from '@/core/chart/charts/instance.js';
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
-import { CreateNotificationService } from '@/core/CreateNotificationService.js';
+import { NotificationService } from '@/core/NotificationService.js';
import { WebhookService } from '@/core/WebhookService.js';
import { HashtagService } from '@/core/HashtagService.js';
import { AntennaService } from '@/core/AntennaService.js';
@@ -44,6 +44,7 @@ import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js';
import { bindThis } from '@/decorators.js';
import { DB_MAX_NOTE_TEXT_LENGTH } from '@/const.js';
import { RoleService } from '@/core/RoleService.js';
+import { MetaService } from '@/core/MetaService.js';
const mutedWordsCache = new Cache<{ userId: UserProfile['userId']; mutedWords: UserProfile['mutedWords']; }[]>(1000 * 60 * 5);
@@ -59,7 +60,7 @@ class NotificationManager {
constructor(
private mutingsRepository: MutingsRepository,
- private createNotificationService: CreateNotificationService,
+ private notificationService: NotificationService,
notifier: { id: User['id']; },
note: Note,
) {
@@ -100,7 +101,7 @@ class NotificationManager {
// 通知される側のユーザーが通知する側のユーザーをミュートしていない限りは通知する
if (!mentioneesMutedUserIds.includes(this.notifier.id)) {
- this.createNotificationService.createNotification(x.target, x.reason, {
+ this.notificationService.createNotification(x.target, x.reason, {
notifierId: this.notifier.id,
noteId: this.note.id,
});
@@ -125,6 +126,7 @@ type Option = {
files?: DriveFile[] | null;
poll?: IPoll | null;
localOnly?: boolean | null;
+ reactionAcceptance?: Note['reactionAcceptance'];
cw?: string | null;
visibility?: string;
visibleUsers?: MinimumUser[] | null;
@@ -181,7 +183,7 @@ export class NoteCreateService implements OnApplicationShutdown {
private globalEventService: GlobalEventService,
private queueService: QueueService,
private noteReadService: NoteReadService,
- private createNotificationService: CreateNotificationService,
+ private notificationService: NotificationService,
private relayService: RelayService,
private federatedInstanceService: FederatedInstanceService,
private hashtagService: HashtagService,
@@ -191,11 +193,12 @@ export class NoteCreateService implements OnApplicationShutdown {
private apDeliverManagerService: ApDeliverManagerService,
private apRendererService: ApRendererService,
private roleService: RoleService,
+ private metaService: MetaService,
private notesChart: NotesChart,
private perUserNotesChart: PerUserNotesChart,
private activeUsersChart: ActiveUsersChart,
private instanceChart: InstanceChart,
- ) {}
+ ) { }
@bindThis
public async create(user: {
@@ -229,7 +232,9 @@ export class NoteCreateService implements OnApplicationShutdown {
if (data.channel != null) data.localOnly = true;
if (data.visibility === 'public' && data.channel == null) {
- if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) {
+ if ((data.text != null) && (await this.metaService.fetch()).sensitiveWords.some(w => data.text!.includes(w))) {
+ data.visibility = 'home';
+ } else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) {
data.visibility = 'home';
}
}
@@ -346,6 +351,7 @@ export class NoteCreateService implements OnApplicationShutdown {
emojis,
userId: user.id,
localOnly: data.localOnly!,
+ reactionAcceptance: data.reactionAcceptance,
visibility: data.visibility as any,
visibleUserIds: data.visibility === 'specified'
? data.visibleUsers
@@ -385,7 +391,7 @@ export class NoteCreateService implements OnApplicationShutdown {
// 投稿を作成
try {
if (insert.hasPoll) {
- // Start transaction
+ // Start transaction
await this.db.transaction(async transactionalEntityManager => {
await transactionalEntityManager.insert(Note, insert);
@@ -408,7 +414,7 @@ export class NoteCreateService implements OnApplicationShutdown {
return insert;
} catch (e) {
- // duplicate key error
+ // duplicate key error
if (isDuplicateKeyValueError(e)) {
const err = new Error('Duplicated note');
err.name = 'duplicated';
@@ -552,7 +558,7 @@ export class NoteCreateService implements OnApplicationShutdown {
}
});
- const nm = new NotificationManager(this.mutingsRepository, this.createNotificationService, user, note);
+ const nm = new NotificationManager(this.mutingsRepository, this.notificationService, user, note);
await this.createMentionedEvents(mentionedUsers, note, nm);